From b9577103acd2d3b960a696e37536da618f5284de Mon Sep 17 00:00:00 2001 From: Flectra Community Bot Date: Sun, 3 Oct 2021 02:12:30 +0000 Subject: [PATCH] Automatic Update form OCA2FC Migrator --- README.md | 2 +- base_tier_validation/__manifest__.py | 2 +- base_tier_validation/models/res_users.py | 55 +++++++++++------------- 3 files changed, 26 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 7dbb0ca..f4f9ce1 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ addon | version | summary [multi_step_wizard](multi_step_wizard/) | 2.0.1.0.0| Multi-Steps Wizards [base_technical_features](base_technical_features/) | 2.0.1.1.0| Access to technical features without activating debug mode [base_tier_validation_formula](base_tier_validation_formula/) | 2.0.2.0.0| Formulas for Base tier validation -[base_tier_validation](base_tier_validation/) | 2.0.2.5.0| Implement a validation process based on tiers. +[base_tier_validation](base_tier_validation/) | 2.0.2.5.1| Implement a validation process based on tiers. [base_search_custom_field_filter](base_search_custom_field_filter/) | 2.0.1.0.0| Add custom filters for fields via UI [base_revision](base_revision/) | 2.0.1.0.1| Keep track of revised document [base_export_manager](base_export_manager/) | 2.0.1.0.1| Manage model export profiles diff --git a/base_tier_validation/__manifest__.py b/base_tier_validation/__manifest__.py index b54ce41..0d5af16 100644 --- a/base_tier_validation/__manifest__.py +++ b/base_tier_validation/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Base Tier Validation", "summary": "Implement a validation process based on tiers.", - "version": "2.0.2.5.0", + "version": "2.0.2.5.1", "development_status": "Mature", "maintainers": ["LoisRForgeFlow"], "category": "Tools", diff --git a/base_tier_validation/models/res_users.py b/base_tier_validation/models/res_users.py index b29456d..f85dbce 100644 --- a/base_tier_validation/models/res_users.py +++ b/base_tier_validation/models/res_users.py @@ -12,37 +12,30 @@ class Users(models.Model): @api.model def review_user_count(self): user_reviews = {} - to_review_docs = {} - reviews = self.env["tier.review"].search( - [ - ("status", "=", "pending"), - ("can_review", "=", True), - ("id", "in", self.env.user.review_ids.ids), - ] - ) - for review in reviews: - record = ( - review.env[review.model] - .with_user(self.env.user) - .search([("id", "=", review.res_id)]) - ) - if not record or record.rejected or not record.can_review: - # Checking that the review is accessible with the permissions - # and to review condition is valid - continue - if not user_reviews.get(review["model"]): - user_reviews[review.model] = { - "name": record._description, - "model": review.model, - "icon": modules.module.get_module_icon( - self.env[review.model]._original_module - ), - "pending_count": 0, - } - docs = to_review_docs.get(review.model) - if (docs and record not in docs) or not docs: - user_reviews[review.model]["pending_count"] += 1 - to_review_docs.setdefault(review.model, []).append(record) + domain = [ + ("status", "=", "pending"), + ("can_review", "=", True), + ("id", "in", self.env.user.review_ids.ids), + ] + review_groups = self.env["tier.review"].read_group(domain, ["model"], ["model"]) + for review_group in review_groups: + model = review_group["model"] + reviews = self.env["tier.review"].search(review_group.get("__domain")) + if reviews: + records = ( + self.env[model] + .with_user(self.env.user) + .search([("id", "in", reviews.mapped("res_id"))]) + .filtered(lambda x: not x.rejected and x.can_review) + ) + if len(records): + record = self.env[model] + user_reviews[model] = { + "name": record._description, + "model": model, + "icon": modules.module.get_module_icon(record._original_module), + "pending_count": len(records), + } return list(user_reviews.values()) @api.model