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.
This commit is contained in:
1 parent
8f3fea326b
commit
d3ef98eafe
2 files changed
+7
-6
No files matched your search
+5
-4
@@ -162,7 +162,7 @@ class Payment(metaclass=PoolMeta):
|
||||
},
|
||||
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 @@ class Payment(metaclass=PoolMeta):
|
||||
'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 @@ class Payment(metaclass=PoolMeta):
|
||||
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
|
||||
|
||||
@@ -157,8 +157,8 @@ Checkout the customer::
|
||||
... 'cvc': '123',
|
||||
... },
|
||||
... )
|
||||
>>> stripe_customer.stripe_token = token.id
|
||||
>>> stripe_customer.save()
|
||||
>>> Customer.write(
|
||||
... [stripe_customer.id], {'stripe_token': token.id}, config.context)
|
||||
|
||||
Run cron::
|
||||
|
||||
|
||||
Reference in new issue
Block a user