Skip to content

Commit f1da5a5

Browse files
committed
fixup! edi_oca: consumer mixin trigger state event
1 parent 948d868 commit f1da5a5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

edi_oca/models/edi_exchange_consumer_mixin.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,16 @@ def _edi_send_via_email(
408408
def write(self, vals):
409409
# Generic event to match a state change
410410
# TODO: this can be added to component_event for models having the state field
411-
if "state" in vals and "state" in self._fields:
411+
state_change = "state" in vals and "state" in self._fields
412+
if state_change:
413+
for rec in self:
414+
rec._event(f"on_edi_{self._table}_before_state_change").notify(
415+
rec, state=vals["state"]
416+
)
417+
res = super().write(vals)
418+
if state_change:
412419
for rec in self:
413420
rec._event(f"on_edi_{self._table}_state_change").notify(
414421
rec, state=vals["state"]
415422
)
416-
return super().write(vals)
423+
return res

0 commit comments

Comments
 (0)