Skip to content

Commit

Permalink
[IMP] base_tier_validation: Change _compute_need_validation()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BernatPForgeFlow authored and JasminSForgeFlow committed Sep 3, 2024
1 parent d55713a commit a64e791
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions base_tier_validation/models/tier_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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",
)
Expand Down

0 comments on commit a64e791

Please sign in to comment.