changeset b21c0e9db3ce in modules/account_payment_stripe:default
details: 
https://hg.tryton.org/modules/account_payment_stripe?cmd=changeset;node=b21c0e9db3ce
description:
        Simplify cron

        issue8201
        issue6117
        issue2286
diffstat:

 __init__.py |   2 ++
 ir.py       |  19 +++++++++++++++++++
 payment.py  |   2 ++
 payment.xml |  46 ++++------------------------------------------
 4 files changed, 27 insertions(+), 42 deletions(-)

diffs (135 lines):

diff -r 3ba37e19ec52 -r b21c0e9db3ce __init__.py
--- a/__init__.py       Thu Apr 11 18:50:54 2019 +0200
+++ b/__init__.py       Fri Apr 12 15:59:24 2019 +0200
@@ -6,6 +6,7 @@
 from . import payment
 from . import party
 from . import routes
+from . import ir
 
 __all__ = ['register', 'routes']
 
@@ -18,6 +19,7 @@
         payment.Group,
         payment.Payment,
         party.Party,
+        ir.Cron,
         module='account_payment_stripe', type_='model')
     Pool.register(
         payment.Checkout,
diff -r 3ba37e19ec52 -r b21c0e9db3ce ir.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/ir.py     Fri Apr 12 15:59:24 2019 +0200
@@ -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"),
+                ])
diff -r 3ba37e19ec52 -r b21c0e9db3ce payment.py
--- a/payment.py        Thu Apr 11 18:50:54 2019 +0200
+++ b/payment.py        Fri Apr 12 15:59:24 2019 +0200
@@ -365,6 +365,7 @@
                         ('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 @@
                     ('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
diff -r 3ba37e19ec52 -r b21c0e9db3ce payment.xml
--- a/payment.xml       Thu Apr 11 18:50:54 2019 +0200
+++ b/payment.xml       Fri Apr 12 15:59:24 2019 +0200
@@ -181,66 +181,28 @@
             <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">

Reply via email to