Automatic Update form OCA2FC Migrator

This commit is contained in:
Flectra Community Bot 2021-10-03 02:12:30 +00:00 committed by OCA2FC Migrator Bot
parent ab3d60c07c
commit b9577103ac
3 changed files with 26 additions and 33 deletions

View File

@ -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

View File

@ -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",

View File

@ -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