diff --git a/edi_oca/models/edi_exchange_consumer_mixin.py b/edi_oca/models/edi_exchange_consumer_mixin.py index 7154e898459..8824a3768d7 100644 --- a/edi_oca/models/edi_exchange_consumer_mixin.py +++ b/edi_oca/models/edi_exchange_consumer_mixin.py @@ -404,3 +404,13 @@ def _edi_send_via_email( # Send the email composer.send_mail() return True + + 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: + for rec in self: + rec._event(f"on_edi_{self._table}_state_change").notify( + rec, state=vals["state"] + ) + return super().write(vals)