Scheduled ActionsΒΆ

Tryton provides a scheduler (aka cron) which can execute methods of models periodically at set intervals.

The planning is managed by ir.cron records which store the method to call and the interval of time between calls. The method must be a class method of a Model which can be called without any parameters.

To register a new method with the scheduler, you must extend the ir.cron model and append the new method to the selection attribute of the method field in __setup__(). The name of the selection must be the model name and the method name joined together with a | between them.


from trytond.model import Model
from trytond.pool import PoolMeta

class Cron(metaclass=PoolMeta):
    __name__ = 'ir.cron'

    def __setup__(cls):
            ('my_model|my_method', "Run my method"),

class MyModel(Model):
    "My Model"
    __name__ = 'my_model'

    def my_method(cls):