Browse Source

Merge pull request #1199 from Eficent/9.0-add-base_tier_validation

[9.0][IMP] base_tier_validation: able to restart validation
pull/663/merge
Jordi Ballester Alomar 7 years ago
committed by GitHub
parent
commit
848702dc2f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      base_tier_validation/__openerp__.py
  2. 13
      base_tier_validation/models/tier_validation.py

2
base_tier_validation/__openerp__.py

@ -4,7 +4,7 @@
{
"name": "Base Tier Validation",
"summary": "Implement a validation process based on tiers.",
"version": "9.0.1.0.0",
"version": "9.0.1.0.1",
"category": "Tools",
"website": "https://github.com/OCA/server-tools",
"author": "Eficent, Odoo Community Association (OCA)",

13
base_tier_validation/models/tier_validation.py

@ -15,7 +15,6 @@ class TierValidation(models.AbstractModel):
_state_to = ['confirmed']
_cancel_state = 'cancel'
# TODO: reset validation?
# TODO: step by step validation?
review_ids = fields.One2many(
@ -69,6 +68,8 @@ class TierValidation(models.AbstractModel):
@api.model
def _calc_reviews_validated(self, reviews):
"""Override for different validation policy."""
if not reviews:
return False
return not any([s != 'approved' for s in reviews.mapped('status')])
@api.model
@ -122,7 +123,7 @@ class TierValidation(models.AbstractModel):
raise ValidationError(_(
"This action needs to be validated for at least "
"one record. \nPlease request a validation."))
if not rec.validated:
if rec.review_ids and not rec.validated:
raise ValidationError(_(
"A validation process is still open for at least "
"one record."))
@ -132,7 +133,7 @@ class TierValidation(models.AbstractModel):
self._check_allow_write_under_validation(vals)):
raise ValidationError(_("The operation is under validation."))
if vals.get(self._state_field) in self._state_from:
self.mapped('review_ids').sudo().unlink()
self.mapped('review_ids').unlink()
return super(TierValidation, self).write(vals)
def _validate_tier(self, tiers=False):
@ -179,3 +180,9 @@ class TierValidation(models.AbstractModel):
})
# TODO: notify? post some msg in chatter?
return created_trs
@api.multi
def restart_validation(self):
for rec in self:
if getattr(rec, self._state_field) in self._state_from:
rec.mapped('review_ids').unlink()
Loading…
Cancel
Save