Replace checkout wizard by values returned by button_action
Closes #14076
This commit is contained in:
@@ -24,7 +24,6 @@ def register():
|
||||
module='account_payment_braintree', type_='model')
|
||||
Pool.register(
|
||||
account.PaymentBraintreeCustomerPaymentMethodDelete,
|
||||
account.PaymentBraintreeCheckout,
|
||||
party.Replace,
|
||||
module='account_payment_braintree', type_='wizard')
|
||||
Pool.register(
|
||||
|
||||
@@ -30,8 +30,7 @@ from trytond.report import Report
|
||||
from trytond.tools import sql_pairing
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.url import http_host
|
||||
from trytond.wizard import (
|
||||
Button, StateAction, StateTransition, StateView, Wizard)
|
||||
from trytond.wizard import Button, StateTransition, StateView, Wizard
|
||||
|
||||
from .common import BraintreeCustomerMethodMixin
|
||||
from .exceptions import BraintreeAccountWarning
|
||||
@@ -115,20 +114,24 @@ class CheckoutMixin:
|
||||
return super().copy(records, default=default)
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('account_payment_braintree.wizard_checkout')
|
||||
@ModelView.button_action('account_payment_braintree.url_checkout')
|
||||
def braintree_checkout(cls, records):
|
||||
for record in records:
|
||||
record.braintree_checkout_id = uuid.uuid4().hex
|
||||
cls.save(records)
|
||||
record.save()
|
||||
return {
|
||||
'url': record.braintree_checkout_url,
|
||||
}
|
||||
|
||||
@property
|
||||
def braintree_checkout_url(self):
|
||||
pool = Pool()
|
||||
database = Transaction().database.name
|
||||
Checkout = pool.get(
|
||||
'account.payment.braintree.checkout', type='wizard')
|
||||
action = Checkout.checkout.get_action()
|
||||
return action['url'] % {
|
||||
ModelData = pool.get('ir.model.data')
|
||||
URL = pool.get('ir.action.url')
|
||||
action = URL(ModelData.get_id(
|
||||
'account_payment_braintree.url_checkout'))
|
||||
return action.url % {
|
||||
'http_host': http_host(),
|
||||
'database': database,
|
||||
'model': self.__class__.__name__,
|
||||
@@ -1261,15 +1264,5 @@ class PaymentBraintreeCustomerPaymentMethodDeleteAsk(ModelView):
|
||||
return methods
|
||||
|
||||
|
||||
class PaymentBraintreeCheckout(Wizard):
|
||||
__name__ = 'account.payment.braintree.checkout'
|
||||
start_state = 'checkout'
|
||||
checkout = StateAction('account_payment_braintree.url_checkout')
|
||||
|
||||
def do_checkout(self, action):
|
||||
action['url'] = self.record.braintree_checkout_url
|
||||
return action, {}
|
||||
|
||||
|
||||
class PaymentBraintreeCheckoutPage(Report):
|
||||
__name__ = 'account.payment.braintree.checkout'
|
||||
|
||||
@@ -293,11 +293,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name">customer_payment_method_delete_ask_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="wizard_checkout">
|
||||
<field name="name">Braintree Checkout</field>
|
||||
<field name="wiz_name">account.payment.braintree.checkout</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.url" id="url_checkout">
|
||||
<field name="name">Braintree Checkout</field>
|
||||
<field name="url">%(http_host)s/%(database)s/account_payment_braintree/checkout/%(model)s/%(id)s</field>
|
||||
|
||||
@@ -24,7 +24,6 @@ def register():
|
||||
ir.Cron,
|
||||
module='account_payment_stripe', type_='model')
|
||||
Pool.register(
|
||||
payment.Checkout,
|
||||
payment.CustomerSourceDetach,
|
||||
party.Replace,
|
||||
module='account_payment_stripe', type_='wizard')
|
||||
|
||||
@@ -30,8 +30,7 @@ from trytond.tools import sql_pairing
|
||||
from trytond.tools.email_ import set_from_header
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.url import http_host
|
||||
from trytond.wizard import (
|
||||
Button, StateAction, StateTransition, StateView, Wizard)
|
||||
from trytond.wizard import Button, StateTransition, StateView, Wizard
|
||||
|
||||
from .common import StripeCustomerMethodMixin
|
||||
from .exceptions import StripeAccountWarning
|
||||
@@ -87,19 +86,23 @@ class CheckoutMixin:
|
||||
return super().copy(records, default=default)
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('account_payment_stripe.wizard_checkout')
|
||||
@ModelView.button_action('account_payment_stripe.url_checkout')
|
||||
def stripe_checkout(cls, records):
|
||||
for record in records:
|
||||
record.stripe_checkout_id = uuid.uuid4().hex
|
||||
cls.save(records)
|
||||
record.save()
|
||||
return {
|
||||
'url': record.stripe_checkout_url,
|
||||
}
|
||||
|
||||
@property
|
||||
def stripe_checkout_url(self):
|
||||
pool = Pool()
|
||||
database = Transaction().database.name
|
||||
Checkout = pool.get('account.payment.stripe.checkout', type='wizard')
|
||||
action = Checkout.checkout.get_action()
|
||||
return action['url'] % {
|
||||
ModelData = pool.get('ir.model.data')
|
||||
URL = pool.get('ir.action.url')
|
||||
action = URL(ModelData.get_id('account_payment_stripe.url_checkout'))
|
||||
return action.url % {
|
||||
'http_host': http_host(),
|
||||
'database': database,
|
||||
'model': self.__class__.__name__,
|
||||
@@ -1947,16 +1950,6 @@ class CustomerIdentical(ModelSQL):
|
||||
where=source.customer != target.customer))
|
||||
|
||||
|
||||
class Checkout(Wizard):
|
||||
__name__ = 'account.payment.stripe.checkout'
|
||||
start_state = 'checkout'
|
||||
checkout = StateAction('account_payment_stripe.url_checkout')
|
||||
|
||||
def do_checkout(self, action):
|
||||
action['url'] = self.record.stripe_checkout_url
|
||||
return action, {}
|
||||
|
||||
|
||||
class CheckoutPage(Report):
|
||||
__name__ = 'account.payment.stripe.checkout'
|
||||
|
||||
|
||||
@@ -289,12 +289,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="string">Find Identical</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="wizard_checkout">
|
||||
<field name="name">Stripe Checkout</field>
|
||||
<field name="wiz_name">account.payment.stripe.checkout</field>
|
||||
<field name="model" eval="None"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.report" id="report_checkout">
|
||||
<field name="name">Stripe Checkout</field>
|
||||
<field name="model" eval="None"/>
|
||||
|
||||
Reference in New Issue
Block a user