|
|
"""Update review status. Called manually from various review operations.
To defer recompute, use context key
`tier_validation_defer_compute_can_review`. Be sure to explicitely call
the method afterwards.
"""
if self.env.context.get("tier_validation_defer_compute_can_review"):
return
reviews = self.filtered(lambda rev: rev.status in ["waiting", "pending"])
if reviews:
# get minimum sequence of all to prevent jumps
next_seq = min(reviews.mapped("sequence"))
for record in reviews:
# if approve by sequence, check sequence has been reached
if record.approve_sequence:
if record.sequence == next_seq:
record.status = "pending"
# if there is no approval sequence go directly to pending state
elif not record.approve_sequence:
record.status = "pending"
if record.status == "pending":
if record.definition_id.notify_on_pending:
record._notify_pending_status(record)
for record in self:
record.can_review = record._can_review_value()
|
|