Skip to content

Commit

Permalink
fixup! edi_oca: consumer mixin trigger state event
Browse files Browse the repository at this point in the history
  • Loading branch information
simahawk committed Nov 29, 2024
1 parent 948d868 commit f1da5a5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions edi_oca/models/edi_exchange_consumer_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,16 @@ def _edi_send_via_email(
def write(self, vals):
# Generic event to match a state change
# TODO: this can be added to component_event for models having the state field
if "state" in vals and "state" in self._fields:
state_change = "state" in vals and "state" in self._fields
if state_change:
for rec in self:
rec._event(f"on_edi_{self._table}_before_state_change").notify(
rec, state=vals["state"]
)
res = super().write(vals)
if state_change:
for rec in self:
rec._event(f"on_edi_{self._table}_state_change").notify(
rec, state=vals["state"]
)
return super().write(vals)
return res

0 comments on commit f1da5a5

Please sign in to comment.