Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] base_tier_validation: Add method to allow remove reviews. #720

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions base_tier_validation/models/tier_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,25 @@
and not rec._context.get("skip_validation_check")
):
raise ValidationError(_("The operation is under validation."))
if vals.get(self._state_field) in self._state_from:
self.mapped("review_ids").unlink()
if rec._allow_to_remove_reviews(vals):
rec.mapped("review_ids").unlink()

Check warning on line 251 in base_tier_validation/models/tier_validation.py

View check run for this annotation

Codecov / codecov/patch

base_tier_validation/models/tier_validation.py#L251

Added line #L251 was not covered by tests
return super(TierValidation, self).write(vals)

def _allow_to_remove_reviews(self, values):
"""Method for deciding whether the elimination of revisions is necessary."""
self.ensure_one()
state_to = values.get(self._state_field)
if not state_to:
return False
state_from = self[self._state_field]
# If you change to _cancel_state
if state_to in (self._cancel_state):
return True

Check warning on line 263 in base_tier_validation/models/tier_validation.py

View check run for this annotation

Codecov / codecov/patch

base_tier_validation/models/tier_validation.py#L263

Added line #L263 was not covered by tests
# If it is changed to _state_from and it was not in _state_from
if state_to in self._state_from and state_from not in self._state_from:
return True

Check warning on line 266 in base_tier_validation/models/tier_validation.py

View check run for this annotation

Codecov / codecov/patch

base_tier_validation/models/tier_validation.py#L266

Added line #L266 was not covered by tests
return False

def _check_state_from_condition(self):
return self.env.context.get("skip_check_state_condition") or (
self._state_field in self._fields
Expand Down
Loading