[IMP] website(_sale,_payment,_sale_picking): improve provider options
When no payment provider is active, admin users should see the 'Activate Stripe' button on the checkout page, allowing them to configure Stripe faster. This commit also disables the provider 'Pay in store when picking the product' in the demo data to improve the testing experience of the eCommerce settings on runbot. task-3235154 closes odoo/odoo#121138 Related: odoo/enterprise#40934 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
committed by
Antoine Vandevenne (anv)
parent
51b1808ebe
commit
6bc5cef302
@@ -16,6 +16,7 @@ This is a bridge module that adds multi-website support for payment providers.
|
||||
'data': [
|
||||
'data/mail_templates.xml',
|
||||
'data/mail_template_data.xml',
|
||||
'data/ir_actions_server_data.xml',
|
||||
'views/payment_provider.xml',
|
||||
'views/res_config_settings_views.xml',
|
||||
'views/donation_templates.xml',
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="action_activate_stripe" model="ir.actions.server">
|
||||
<field name="name">Activate Stripe</field>
|
||||
<field name="model_id" ref="website_payment.model_payment_provider"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">
|
||||
menu = env.ref('website.menu_website_website_settings', raise_if_not_found=False)
|
||||
menu_id = menu and menu.id
|
||||
action = env.company._run_payment_onboarding_step(menu_id=menu_id)
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -49,9 +49,7 @@ class ResConfigSettings(models.TransientModel):
|
||||
self.ensure_one()
|
||||
if not self.is_stripe_supported_country:
|
||||
return False
|
||||
menu = self.env.ref('website.menu_website_website_settings', raise_if_not_found=False)
|
||||
menu_id = menu and menu.id
|
||||
return self.env.company._run_payment_onboarding_step(menu_id=menu_id)
|
||||
return self.env['ir.actions.actions']._for_xml_id('website_payment.action_activate_stripe')
|
||||
|
||||
def action_configure_first_provider(self):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -10,20 +10,40 @@
|
||||
<block title="Shop - Payment" id="div_website_payment">
|
||||
<setting id="website_payment" string="Activate Payments" help="Support most payment methods; Visa, Mastercard, Maestro, Google Pay, Apple Pay, etc. as well as recurring charges.">
|
||||
<div class="content-group">
|
||||
<div class="row mt8 ms-4" attrs="{'invisible': [('providers_state', '=', 'other_than_paypal')]}">
|
||||
<div class="row" attrs="{'invisible': [('providers_state', '=', 'other_than_paypal')]}">
|
||||
<field name="providers_state" invisible="1"/>
|
||||
<field name="is_stripe_supported_country" invisible="1"/>
|
||||
<button attrs="{'invisible': [('is_stripe_supported_country', '=', False)]}"
|
||||
name="action_activate_stripe" type="object" string="Activate Stripe" class="btn-primary col-auto"/>
|
||||
<div attrs="{'invisible': [('is_stripe_supported_country', '=', True)]}" class="col-auto" data-bs-toggle="tooltip" title="Stripe Connect is not available in your country, please use another payment provider.">
|
||||
<button string="Activate Stripe" class="btn-primary pe-none" disabled=""
|
||||
style="pointer-events: none;"/>
|
||||
<div class="oe_inline"
|
||||
attrs="{'invisible': [('is_stripe_supported_country', '=', False)]}"
|
||||
>
|
||||
<button string="Activate Stripe" name="action_activate_stripe" type="object" class="btn-primary"/>
|
||||
</div>
|
||||
<button type="action" name="%(payment.action_payment_provider)d" string="View Alternatives" class="btn-link" icon="oi-arrow-right"/>
|
||||
<div class="oe_inline"
|
||||
title="Stripe Connect is not available in your country, please use another payment provider."
|
||||
attrs="{'invisible': [('is_stripe_supported_country', '=', True)]}"
|
||||
>
|
||||
<button string="Activate Stripe" class="btn-primary" disabled=""/>
|
||||
</div>
|
||||
<button type="action"
|
||||
name="%(payment.action_payment_provider)d"
|
||||
string="View Alternatives"
|
||||
class="btn-link oe_inline"
|
||||
icon="oi-arrow-right"
|
||||
/>
|
||||
</div>
|
||||
<div class="row mt8 ms-4" attrs="{'invisible': [('providers_state', '!=', 'other_than_paypal')]}">
|
||||
<button name="action_configure_first_provider" type="object" class="btn-primary col-auto"><field name="first_provider_label" nolabel="1" class="oe_inline"/></button>
|
||||
<button type="action" name="%(payment.action_payment_provider)d" string="View other providers " class="btn-link col-auto" icon="oi-arrow-right"/>
|
||||
<div attrs="{'invisible': [('providers_state', '!=', 'other_than_paypal')]}">
|
||||
<button name="action_configure_first_provider"
|
||||
type="object"
|
||||
class="btn-primary col-auto"
|
||||
>
|
||||
<field name="first_provider_label" nolabel="1" class="oe_inline"/>
|
||||
</button>
|
||||
<button type="action"
|
||||
name="%(payment.action_payment_provider)d"
|
||||
string="View other providers "
|
||||
class="btn-link col-auto"
|
||||
icon="oi-arrow-right"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</setting>
|
||||
|
||||
@@ -1483,6 +1483,9 @@ class WebsiteSale(http.Controller):
|
||||
'partner': order.partner_invoice_id,
|
||||
'order': order,
|
||||
'payment_action_id': request.env.ref('payment.action_payment_provider').id,
|
||||
'action_activate_stripe_id': request.env.ref(
|
||||
'website_payment.action_activate_stripe'
|
||||
).id,
|
||||
}
|
||||
payment_form_values = {
|
||||
**sale_portal.CustomerPortal._get_payment_values(
|
||||
|
||||
@@ -1981,8 +1981,10 @@
|
||||
<div class="oe_structure clearfix mt-3" id="oe_structure_website_sale_payment_1"/>
|
||||
|
||||
<t t-if="website_sale_order.amount_total">
|
||||
<div t-if="providers or tokens" id="payment_method" class="mt-3">
|
||||
<div class="mt-3">
|
||||
<h3 class="mb24">Pay with </h3>
|
||||
</div>
|
||||
<div t-if="providers or tokens" id="payment_method">
|
||||
<t t-call="payment.checkout">
|
||||
<t t-set="footer_template_id" t-value="'website_sale.payment_footer'"/>
|
||||
<t t-set="submit_button_label">Pay Now</t>
|
||||
@@ -1990,17 +1992,31 @@
|
||||
</div>
|
||||
<div t-else="" class="alert alert-warning">
|
||||
<strong>No suitable payment option could be found.</strong><br/>
|
||||
If you believe that it is an error, please contact the website administrator.
|
||||
<div t-if="not request.env.is_admin()">
|
||||
If you believe that it is an error, please contact the website administrator.
|
||||
</div>
|
||||
<div class="mt-2" groups="base.group_system">
|
||||
<a t-if="request.env.company.country_id.is_stripe_supported_country"
|
||||
t-attf-href="/web#action=#{action_activate_stripe_id}"
|
||||
role="button"
|
||||
class="btn btn-primary"
|
||||
t-out="'ACTIVATE STRIPE'"
|
||||
/>
|
||||
<div t-else=""
|
||||
class="d-inline"
|
||||
title="Stripe Connect is not available in your country, please use another payment provider."
|
||||
>
|
||||
<button t-out="'ACTIVATE STRIPE'" class="btn btn-primary" disabled="true"/>
|
||||
</div>
|
||||
<a role="button"
|
||||
class="btn-link alert-warning ps-2"
|
||||
t-attf-href="/web#action=#{payment_action_id}"
|
||||
>
|
||||
<strong><i class="oi oi-arrow-right"></i> View alternatives</strong>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<div t-if="not providers" class="mt-2">
|
||||
<a role="button" class="btn-link"
|
||||
groups="base.group_system"
|
||||
t-attf-href="/web#action=#{payment_action_id}">
|
||||
<i class="oi oi-arrow-right"></i> Add payment providers
|
||||
</a>
|
||||
</div>
|
||||
<div class="js_payment mt-3" t-if="not website_sale_order.amount_total" id="payment_method" name="o_website_sale_free_cart">
|
||||
<form name="o_wsale_confirm_order" target="_self" action="/shop/payment/validate" method="post">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()" t-nocache="The csrf token must always be up to date."/>
|
||||
|
||||
@@ -137,7 +137,6 @@ registry.category("web_tour.tours").add('shop_sale_loyalty', {
|
||||
},
|
||||
{
|
||||
content: "check total is unchanged once we land on payment page",
|
||||
extra_trigger: '#payment_method h3:contains("Pay with")',
|
||||
trigger: 'tr#order_total .oe_currency_value:contains("967.50")',
|
||||
run: function () {}, // it's a check
|
||||
},
|
||||
|
||||
@@ -15,6 +15,9 @@ Allows customers to pay for their orders at a shop, instead of paying online.
|
||||
'views/templates.xml',
|
||||
'views/delivery_view.xml'
|
||||
],
|
||||
'demo': [
|
||||
'data/demo.xml',
|
||||
],
|
||||
'assets': {
|
||||
'web.assets_frontend': [
|
||||
'website_sale_picking/static/src/js/checkout_form.js'
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record id="website_sale_picking.payment_provider_onsite" model="payment.provider">
|
||||
<field name="state">disabled</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -39,6 +39,7 @@ class TestUi(HttpCase):
|
||||
'name': 'Example shipping On Site',
|
||||
'product_id': self.env.ref('website_sale_picking.onsite_delivery_product').id,
|
||||
})
|
||||
self.env.ref("website_sale_picking.payment_provider_onsite").state = 'enabled'
|
||||
self.env.ref("website_sale_picking.payment_provider_onsite").is_published = True
|
||||
|
||||
self.start_tour('/shop', 'onsite_payment_tour')
|
||||
|
||||
Reference in New Issue
Block a user