changeset 0b4eedd4352d in modules/account_payment_stripe:default
details: 
https://hg.tryton.org/modules/account_payment_stripe?cmd=changeset;node=0b4eedd4352d
description:
        Add setter to stripe_customer_source and write stripe_token in scenario

        Since issue7985, Function fields must have a setter method if they are 
not
        read only. And proteus does not save anymore readonly fields.
diffstat:

 payment.py                                |  9 +++++----
 tests/scenario_account_payment_stripe.rst |  4 ++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diffs (47 lines):

diff -r c2ddb254d6cf -r 0b4eedd4352d payment.py
--- a/payment.py        Sun Mar 31 00:15:09 2019 +0100
+++ b/payment.py        Sun Mar 31 13:31:29 2019 +0200
@@ -162,7 +162,7 @@
                 },
             depends=[
                 'stripe_account', 'stripe_token', 'stripe_customer', 'state']),
-        'get_stripe_customer_source')
+        'get_stripe_customer_source', setter='set_stripe_customer_source')
     stripe_account = fields.Function(fields.Many2One(
             'account.payment.stripe.account', "Stripe Account"),
         'on_change_with_stripe_account')
@@ -190,9 +190,6 @@
                     'depends': ['state', 'stripe_capture_needed'],
                     },
                 })
-        # As there is not setter to avoid the cost of validation,
-        # the readonly attribute must be unset.
-        cls.stripe_customer_source_selection._field.readonly = False
 
     @classmethod
     def __register__(cls, module_name):
@@ -258,6 +255,10 @@
     def get_stripe_customer_source(self, name):
         return self.stripe_customer_source
 
+    @classmethod
+    def set_stripe_customer_source(cls, payments, name, value):
+        pass
+
     def get_stripe_checkout_needed(self, name):
         return (self.journal.process_method == 'stripe'
             and not self.stripe_token
diff -r c2ddb254d6cf -r 0b4eedd4352d tests/scenario_account_payment_stripe.rst
--- a/tests/scenario_account_payment_stripe.rst Sun Mar 31 00:15:09 2019 +0100
+++ b/tests/scenario_account_payment_stripe.rst Sun Mar 31 13:31:29 2019 +0200
@@ -157,8 +157,8 @@
     ...         'cvc': '123',
     ...         },
     ...     )
-    >>> stripe_customer.stripe_token = token.id
-    >>> stripe_customer.save()
+    >>> Customer.write(
+    ...     [stripe_customer.id], {'stripe_token': token.id}, config.context)
 
 Run cron::
 

Reply via email to