From 7eeb44e1f22b587a2d6d7964e5ff17263a2b652d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 12 Apr 2019 15:59:24 +0200 Subject: [PATCH] Simplify cron issue8201 issue6117 issue2286 --- __init__.py | 2 ++ ir.py | 17 +++++++++++++++ marketing_automation.xml | 28 ++----------------------- tests/scenario_marketing_automation.rst | 6 ++---- 4 files changed, 23 insertions(+), 30 deletions(-) create mode 100644 ir.py diff --git a/__init__.py b/__init__.py index 096a8b199d..6aa43f28e3 100644 --- a/__init__.py +++ b/__init__.py @@ -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, diff --git a/ir.py b/ir.py new file mode 100644 index 0000000000..ecb9014da2 --- /dev/null +++ b/ir.py @@ -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"), + ]) diff --git a/marketing_automation.xml b/marketing_automation.xml index b0b2ae0731..236dadc237 100644 --- a/marketing_automation.xml +++ b/marketing_automation.xml @@ -299,39 +299,15 @@ this repository contains the full copyright notices and license terms. --> html - - user_marketing_automation - Cron Marketing Automation - - - - - - - - Trigger Scenarios - - - + marketing.automation.scenario|trigger hours - - - marketing.automation.scenario - trigger - Process Record Activity - - - + marketing.automation.record.activity|process minutes - - - marketing.automation.record.activity - process diff --git a/tests/scenario_marketing_automation.rst b/tests/scenario_marketing_automation.rst index ce3a89a074..d4de514500 100644 --- a/tests/scenario_marketing_automation.rst +++ b/tests/scenario_marketing_automation.rst @@ -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')