From a3a85f310bf5157fb05f0fe3f64b44b537d791c5 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 | 14 ++++++++++++ payment.py | 1 + payment.xml | 24 +-------------------- tests/scenario_account_payment_clearing.rst | 4 ++-- 5 files changed, 20 insertions(+), 25 deletions(-) create mode 100644 ir.py diff --git a/__init__.py b/__init__.py index d9b70df15a..1020d96dca 100644 --- a/__init__.py +++ b/__init__.py @@ -4,6 +4,7 @@ from trytond.pool import Pool from . import payment from . import account from . import statement +from . import ir def register(): @@ -12,6 +13,7 @@ def register(): payment.Payment, payment.SucceedStart, account.Move, + ir.Cron, module='account_payment_clearing', type_='model') Pool.register( statement.Statement, diff --git a/ir.py b/ir.py new file mode 100644 index 0000000000..b5b31c8add --- /dev/null +++ b/ir.py @@ -0,0 +1,14 @@ +# 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.append( + ('account.payment.journal|cron_post_clearing_moves', + "Post Clearing Moves")) diff --git a/payment.py b/payment.py index 2eda57dd05..da46bbe313 100644 --- a/payment.py +++ b/payment.py @@ -47,6 +47,7 @@ class Journal(metaclass=PoolMeta): ('origin.journal.id', '=', journal.id, 'account.payment'), ('state', '=', 'draft'), + ('company', '=', Transaction().context.get('company')), ])) Move.post(moves) diff --git a/payment.xml b/payment.xml index 39cdf0e5c8..ba58a46ca8 100644 --- a/payment.xml +++ b/payment.xml @@ -39,32 +39,10 @@ this repository contains the full copyright notices and license terms. --> - - user_cron_post_clearing_moves - Cron Post Clearing Moves - - - - - - - - - - - - - Post Clearing Moves - - + account.payment.journal|cron_post_clearing_moves days - - account.payment.journal - cron_post_clearing_moves diff --git a/tests/scenario_account_payment_clearing.rst b/tests/scenario_account_payment_clearing.rst index 361c8fa9cb..5b7521e4d0 100644 --- a/tests/scenario_account_payment_clearing.rst +++ b/tests/scenario_account_payment_clearing.rst @@ -195,8 +195,8 @@ Succeed payment and post clearing:: >>> Cron = Model.get('ir.cron') >>> Company = Model.get('company.company') >>> cron_post_clearing_moves, = Cron.find([ - ... ('model', '=', 'account.payment.journal'), - ... ('function', '=', 'cron_post_clearing_moves'), + ... ('method', '=', + ... 'account.payment.journal|cron_post_clearing_moves'), ... ]) >>> cron_post_clearing_moves.companies.append(Company(company.id)) >>> cron_post_clearing_moves.click('run_once')