Skip to content

Commit

Permalink
edi_oca: consumer mixin trigger state event
Browse files Browse the repository at this point in the history
Models using the consumer mixing and having a state field
will now trigger a specific event when the state is updated.
  • Loading branch information
simahawk committed Nov 28, 2024
1 parent bf74ebc commit 202ecda
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions edi_oca/models/edi_exchange_consumer_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,13 @@ def _edi_send_via_email(
# Send the email
composer.send_mail()
return True

Check warning on line 406 in edi_oca/models/edi_exchange_consumer_mixin.py

View check run for this annotation

Codecov / codecov/patch

edi_oca/models/edi_exchange_consumer_mixin.py#L405-L406

Added lines #L405 - L406 were not covered by tests

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)

0 comments on commit 202ecda

Please sign in to comment.