Files
tryton/trytond/doc/topics/triggers.rst
T

28 lines
922 B
ReStructuredText
Raw Normal View History

2016-07-29 10:33:18 +02:00
.. _topics-triggers:
========
Triggers
========
2022-03-27 16:06:09 +02:00
Triggers allow to define methods of :class:`~trytond.model.Model` that are
2020-03-28 17:13:12 +01:00
called at the end of the transaction when one of those events happen to a
record:
2016-07-29 10:33:18 +02:00
* On Creation
* On Modification
* On Deletions
* On Time: When a condition changes over time.
The method signature is::
<method name>(cls, records, trigger)
Where ``records`` is the list of records that triggered the event and
``trigger`` is the ``ir.trigger`` instance which is triggered.
2016-07-29 10:33:18 +02:00
Triggers are defined by records of ``ir.trigger``. Each record must define a
pyson condition which will be evaluated when the event occurs. Only those
2016-07-29 10:33:18 +02:00
records for which the condition is evaluated to true will be processed by the
trigger with the exception of modification triggers which will only process the
2016-07-29 10:33:18 +02:00
records for which the condition is evaluated to false before and evaluated to
true after the modification.