Simplify cron
issue8201 issue6117 issue2286
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
from trytond.pool import Pool
|
||||
|
||||
from . import ir
|
||||
from . import marketing_automation
|
||||
from . import web
|
||||
from . import party
|
||||
@@ -14,6 +15,7 @@ __all__ = ['register', 'routes']
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
ir.Cron,
|
||||
marketing_automation.Scenario,
|
||||
marketing_automation.Activity,
|
||||
marketing_automation.Record,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
|
||||
class Cron(metaclass=PoolMeta):
|
||||
__name__ = 'ir.cron'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls.method.selection.extend([
|
||||
('marketing.automation.scenario|trigger',
|
||||
"Trigger Marketing Scenarios"),
|
||||
('marketing.automation.record.activity|process',
|
||||
"Process Marketing Activity"),
|
||||
])
|
||||
@@ -299,39 +299,15 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="template_extension">html</field>
|
||||
</record>
|
||||
|
||||
<record model="res.user" id="user_marketing_automation">
|
||||
<field name="login">user_marketing_automation</field>
|
||||
<field name="name">Cron Marketing Automation</field>
|
||||
<field name="active" eval="False"/>
|
||||
</record>
|
||||
<record model="res.user-res.group" id="user_marketing_automation_group_marketing_automation">
|
||||
<field name="user" ref="user_marketing_automation"/>
|
||||
<field name="group" ref="marketing.group_marketing"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.cron" id="cron_scenario_trigger">
|
||||
<field name="name">Trigger Scenarios</field>
|
||||
<field name="request_user" ref="res.user_admin"/>
|
||||
<field name="user" ref="user_marketing_automation"/>
|
||||
<field name="active" eval="True"/>
|
||||
<field name="method">marketing.automation.scenario|trigger</field>
|
||||
<field name="interval_number" eval="1"/>
|
||||
<field name="interval_type">hours</field>
|
||||
<field name="number_calls" eval="-1"/>
|
||||
<field name="repeat_missed" eval="False"/>
|
||||
<field name="model">marketing.automation.scenario</field>
|
||||
<field name="function">trigger</field>
|
||||
</record>
|
||||
<record model="ir.cron" id="cron_record_activity_process">
|
||||
<field name="name">Process Record Activity</field>
|
||||
<field name="request_user" ref="res.user_admin"/>
|
||||
<field name="user" ref="user_marketing_automation"/>
|
||||
<field name="active" eval="True"/>
|
||||
<field name="method">marketing.automation.record.activity|process</field>
|
||||
<field name="interval_number" eval="15"/>
|
||||
<field name="interval_type">minutes</field>
|
||||
<field name="number_calls" eval="-1"/>
|
||||
<field name="repeat_missed" eval="False"/>
|
||||
<field name="model">marketing.automation.record.activity</field>
|
||||
<field name="function">process</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
@@ -87,12 +87,10 @@ Trigger scenario::
|
||||
|
||||
>>> Cron = Model.get('ir.cron')
|
||||
>>> cron_trigger, = Cron.find([
|
||||
... ('model', '=', 'marketing.automation.scenario'),
|
||||
... ('function', '=', 'trigger'),
|
||||
... ('method', '=', 'marketing.automation.scenario|trigger'),
|
||||
... ])
|
||||
>>> cron_process, = Cron.find([
|
||||
... ('model', '=', 'marketing.automation.record.activity'),
|
||||
... ('function', '=', 'process'),
|
||||
... ('method', '=', 'marketing.automation.record.activity|process'),
|
||||
... ])
|
||||
>>> cron_trigger.click('run_once')
|
||||
>>> cron_process.click('run_once')
|
||||
|
||||
Reference in New Issue
Block a user