Browse Source

[IMP] partner_tier_validation (Prevent bypass)

This prevents a scenario where a user can bypass validation by moving the partner to a 'cancel' stage and then moving it back to confirmed.
14.0
Patrick Wilson 3 years ago
parent
commit
1381d57f67
  1. 4
      partner_tier_validation/models/res_partner.py

4
partner_tier_validation/models/res_partner.py

@ -9,7 +9,7 @@ class ResPartner(models.Model):
_inherit = ["res.partner", "tier.validation"] _inherit = ["res.partner", "tier.validation"]
_tier_validation_buttons_xpath = "/form/header/field[@name='state']" _tier_validation_buttons_xpath = "/form/header/field[@name='state']"
_state_from = ["draft"]
_state_from = ["draft", "cancel"]
_state_to = ["confirmed"] _state_to = ["confirmed"]
_cancel_state = ["inactive"] _cancel_state = ["inactive"]
_tier_validation_manual_config = False _tier_validation_manual_config = False
@ -45,6 +45,6 @@ class ResPartner(models.Model):
stage = self.env["res.partner.stage"].browse(stage_id) stage = self.env["res.partner.stage"].browse(stage_id)
vals["state"] = stage.state vals["state"] = stage.state
res = super().write(vals) res = super().write(vals)
if "stage_id" in vals:
if "stage_id" in vals and vals.get("stage_id") in self._state_from:
self.restart_validation() self.restart_validation()
return res return res
Loading…
Cancel
Save