Skip to content

Commit 202ecda

Browse files
committed
edi_oca: consumer mixin trigger state event
Models using the consumer mixing and having a state field will now trigger a specific event when the state is updated.
1 parent bf74ebc commit 202ecda

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

edi_oca/models/edi_exchange_consumer_mixin.py

+10
Original file line numberDiff line numberDiff line change
@@ -404,3 +404,13 @@ def _edi_send_via_email(
404404
# Send the email
405405
composer.send_mail()
406406
return True
407+
408+
def write(self, vals):
409+
# Generic event to match a state change
410+
# TODO: this can be added to component_event for models having the state field
411+
if "state" in vals and "state" in self._fields:
412+
for rec in self:
413+
rec._event(f"on_edi_{self._table}_state_change").notify(
414+
rec, state=vals["state"]
415+
)
416+
return super().write(vals)

0 commit comments

Comments
 (0)