Simplify cron
issue8201 issue6117 issue2286
This commit is contained in:
1 parent
fe55dfba4c
commit
a3a85f310b
5 files changed
+20
-25
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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"))
|
||||
@@ -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)
|
||||
|
||||
|
||||
+1
-23
@@ -39,32 +39,10 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="model" search="[('model', '=', 'account.payment')]"/>
|
||||
</record>
|
||||
|
||||
<record model="res.user" id="user_post_clearing_moves">
|
||||
<field name="login">user_cron_post_clearing_moves</field>
|
||||
<field name="name">Cron Post Clearing Moves</field>
|
||||
<field name="signature"></field>
|
||||
<field name="active" eval="False"/>
|
||||
</record>
|
||||
<record model="res.user-res.group"
|
||||
id="user_post_clearing_moves_group_account">
|
||||
<field name="user" ref="user_post_clearing_moves"/>
|
||||
<field name="group" ref="account.group_account"/>
|
||||
</record>
|
||||
<record model="res.user-res.group"
|
||||
id="user_post_clearing_moves_group_payment">
|
||||
<field name="user" ref="user_post_clearing_moves"/>
|
||||
<field name="group" ref="account_payment.group_payment"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.cron" id="cron_post_clearing_moves">
|
||||
<field name="name">Post Clearing Moves</field>
|
||||
<field name="request_user" ref="res.user_admin"/>
|
||||
<field name="user" ref="user_post_clearing_moves"/>
|
||||
<field name="method">account.payment.journal|cron_post_clearing_moves</field>
|
||||
<field name="interval_number" eval="1"/>
|
||||
<field name="interval_type">days</field>
|
||||
<field name="repeat_missed" eval="False"/>
|
||||
<field name="model">account.payment.journal</field>
|
||||
<field name="function">cron_post_clearing_moves</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -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')
|
||||
|
||||
Reference in new issue
Block a user