Simplify cron

issue8201
issue6117
issue2286
This commit is contained in:
Cédric Krier committed 2019-04-12 15:59:24 +02:00
1 parent 4c2025e527
commit ffffb8296f
4 files changed
+27 -42

No files matched your search

+2
View File
@@ -6,6 +6,7 @@ from trytond.pool import Pool
from . import payment
from . import party
from . import routes
from . import ir
__all__ = ['register', 'routes']
@@ -18,6 +19,7 @@ def register():
payment.Group,
payment.Payment,
party.Party,
ir.Cron,
module='account_payment_stripe', type_='model')
Pool.register(
payment.Checkout,
+19
View File
@@ -0,0 +1,19 @@
# 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([
('account.payment|stripe_charge', "Charge Stripe Payments"),
('account.payment|stripe_capture_', "Capture Stripe Payments"),
('account.payment.stripe.customer|stripe_create',
"Create Stripe Customer"),
('account.payment.stripe.customer|stripe_delete',
"Delete Stripe Customer"),
])
+2
View File
@@ -365,6 +365,7 @@ class Payment(metaclass=PoolMeta):
('stripe_customer.stripe_customer_id', '!=', None),
],
('stripe_charge_id', '=', None),
('company', '=', Transaction().context.get('company')),
])
for payment in payments:
if (payment.stripe_charge_id
@@ -443,6 +444,7 @@ class Payment(metaclass=PoolMeta):
('stripe_charge_id', '!=', None),
('stripe_captured', '=', False),
('stripe_capture', '=', True),
('company', '=', Transaction().context.get('company')),
])
for payment in payments:
if (not payment.stripe_charge_id
+4 -42
View File
@@ -181,66 +181,28 @@ this repository contains the full copyright notices and license terms. -->
<field name="template_extension">html</field>
</record>
<record model="res.user" id="user_stripe">
<field name="login">user_cron_stripe</field>
<field name="name">Cron Stripe</field>
<field name="active" eval="False"/>
</record>
<record model="res.user-res.group" id="user_stripe_group_payment">
<field name="user" ref="user_stripe"/>
<field name="group" ref="account_payment.group_payment"/>
</record>
<record model="ir.cron" id="cron_charge">
<field name="name">Charge Stripe Payments</field>
<field name="request_user" ref="res.user_admin"/>
<field name="user" ref="user_stripe"/>
<field name="active" eval="True"/>
<field name="method">account.payment|stripe_charge</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">account.payment</field>
<field name="function">stripe_charge</field>
</record>
<record model="ir.cron" id="cron_capture">
<field name="name">Capture Stripe Payments</field>
<field name="request_user" ref="res.user_admin"/>
<field name="user" ref="user_stripe"/>
<field name="active" eval="True"/>
<field name="method">account.payment|stripe_capture_</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">account.payment</field>
<field name="function">stripe_capture_</field>
</record>
<record model="ir.cron" id="cron_create_customer">
<field name="name">Create Stripe Customer</field>
<field name="request_user" ref="res.user_admin"/>
<field name="user" ref="user_stripe"/>
<field name="active" eval="True"/>
<field name="method">account.payment.stripe.customer|stripe_create</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">account.payment.stripe.customer</field>
<field name="function">stripe_create</field>
</record>
<record model="ir.cron" id="cron_delete_customer">
<field name="name">Delete Stripe Customer</field>
<field name="request_user" ref="res.user_admin"/>
<field name="user" ref="user_stripe"/>
<field name="active" eval="True"/>
<field name="method">account.payment.stripe.customer|stripe_delete</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">account.payment.stripe.customer</field>
<field name="function">stripe_delete</field>
</record>
</data>
<data noupdate="1">