Add button to update Braintree customer

Closes #13469
This commit is contained in:
Cédric Krier
2024-08-22 18:39:53 +02:00
parent ee3deba96b
commit 885e40d4be
5 changed files with 15 additions and 0 deletions
@@ -1,3 +1,4 @@
* Add button to update customer
* Warn when changing credential
Version 7.2.0 - 2024-04-29
@@ -975,6 +975,10 @@ class PaymentBraintreeCustomer(
'invisible': Bool(Eval('braintree_nonce')),
'depends': ['braintree_nonce'],
},
'braintree_update': {
'invisible': ~Eval('braintree_customer_id'),
'depends': ['braintree_customer_id'],
},
'delete_payment_method': {
'invisible': ~Eval('braintree_customer_id'),
'depends': ['braintree_customer_id'],
@@ -1083,8 +1087,11 @@ class PaymentBraintreeCustomer(
return params
@classmethod
@ModelView.button
def braintree_update(cls, customers):
for customer in customers:
if not customer.braintree_customer_id:
continue
gateway = customer.braintree_account.gateway()
try:
gateway.customer.update(
@@ -293,6 +293,11 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">braintree_checkout</field>
<field name="string">Add Card</field>
</record>
<record model="ir.model.button" id="customer_braintree_update_button">
<field name="model">account.payment.braintree.customer</field>
<field name="name">braintree_update</field>
<field name="string">Update</field>
</record>
<record model="ir.cron" id="cron_create_customer">
<field name="method">account.payment.braintree.customer|braintree_create</field>
@@ -16,6 +16,7 @@ this repository contains the full copyright notices and license terms. -->
<group id="buttons" col="-1" colspan="4">
<button name="braintree_checkout"/>
<button name="braintree_update"/>
<button name="delete_payment_method"/>
</group>
@@ -6,4 +6,5 @@ this repository contains the full copyright notices and license terms. -->
<field name="braintree_account" expand="1"/>
<field name="braintree_customer_id"/>
<button name="braintree_checkout"/>
<button name="braintree_update"/>
</tree>