From a64e79194efdef7589798131f0930ab751aaccba Mon Sep 17 00:00:00 2001 From: BernatPForgeFlow Date: Wed, 24 Jul 2024 10:13:02 +0200 Subject: [PATCH] [IMP] base_tier_validation: Change _compute_need_validation() A document does not need validation only if there are no pending reviews, otherwise we should evaluate as True. We add a condition in request_validation to be able to request more than one time if there are new tier validations. --- base_tier_validation/models/tier_validation.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/base_tier_validation/models/tier_validation.py b/base_tier_validation/models/tier_validation.py index 54b2a7de26..d00e1df6b2 100644 --- a/base_tier_validation/models/tier_validation.py +++ b/base_tier_validation/models/tier_validation.py @@ -233,10 +233,12 @@ def _compute_need_validation(self): ] ) ) - valid_tiers = any([rec.evaluate_tier(tier) for tier in tiers]) - rec.need_validation = ( - not rec.review_ids and valid_tiers and rec._check_state_from_condition() - ) + valid_tiers = tiers.filtered(lambda x: rec.evaluate_tier(x)) + requested_tiers = rec.review_ids.filtered( + lambda x: x.status != "pending" + ).mapped("definition_id") + new_tiers = valid_tiers - requested_tiers + rec.need_validation = new_tiers and rec._check_state_from_condition() def evaluate_tier(self, tier): if tier.definition_domain: @@ -620,6 +622,7 @@ def request_validation(self): [ ("model", "=", self._name), ("company_id", "in", [False] + self.env.company.ids), + ("id", "not in", rec.review_ids.mapped("definition_id").ids), ], order="sequence desc", )