Add button to update Stripe customer

Closes #13468
This commit is contained in:
Cédric Krier committed 2024-08-22 18:33:39 +02:00
1 parent 8468d694ac
commit 3abe5f6fc5
5 files changed
+15

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Add button to update customer
* Add Stripe pull button to payment
* Warn when changing credential
@@ -1459,6 +1459,10 @@ class Customer(CheckoutMixin, DeactivableMixin, ModelSQL, ModelView):
'invisible': ~Eval('stripe_checkout_needed', False),
'depends': ['stripe_checkout_needed'],
},
'stripe_update': {
'invisible': ~Eval('stripe_customer_id'),
'depends': ['stripe_customer_id'],
},
'detach_source': {
'invisible': ~Eval('stripe_customer_id'),
'depends': ['stripe_customer_id'],
@@ -1572,8 +1576,11 @@ class Customer(CheckoutMixin, DeactivableMixin, ModelSQL, ModelView):
}
@classmethod
@ModelView.button
def stripe_update(cls, customers):
for customer in customers:
if not customer.stripe_customer_id:
continue
try:
stripe.Customer.modify(
customer.stripe_customer_id,
@@ -273,6 +273,11 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">stripe_checkout</field>
<field name="string">Add Card</field>
</record>
<record model="ir.model.button" id="customer_stripe_update_button">
<field name="model">account.payment.stripe.customer</field>
<field name="name">stripe_update</field>
<field name="string">Update</field>
</record>
<record model="ir.model.button" id="customer_source_detach_button">
<field name="model">account.payment.stripe.customer</field>
<field name="name">detach_source</field>
@@ -13,6 +13,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="stripe_customer_id"/>
<group id="buttons" col="-1" colspan="4">
<button name="stripe_checkout"/>
<button name="stripe_update"/>
<button name="detach_source"/>
<button name="find_identical"/>
</group>
@@ -7,4 +7,5 @@ this repository contains the full copyright notices and license terms. -->
<field name="stripe_customer_id"/>
<field name="stripe_token"/>
<button name="stripe_checkout"/>
<button name="stripe_update"/>
</tree>