Skip to content

Commit

Permalink
[MIG] website_sale_checkout_skip_payment: Migration to 18.0
Browse files Browse the repository at this point in the history
TT51372
  • Loading branch information
pilarvargas-tecnativa committed Oct 22, 2024
1 parent 56ede45 commit ae069c9
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 159 deletions.
1 change: 1 addition & 0 deletions website_sale_checkout_skip_payment/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Contributors
- David Vidal
- Alexandre Díaz
- Carlos Roca
- Pilar Vargas

- Martin Wilderoth <[email protected]>
- `Studio73 <https://www.studio73.es>`__:
Expand Down
2 changes: 1 addition & 1 deletion website_sale_checkout_skip_payment/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Website Sale Checkout Skip Payment",
"summary": "Skip payment for logged users in checkout process",
"version": "16.0.1.2.1",
"version": "18.0.1.0.0",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
24 changes: 8 additions & 16 deletions website_sale_checkout_skip_payment/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@


class CheckoutSkipPaymentWebsite(WebsiteSale):
@http.route()
def shop_payment_get_status(self, sale_order_id, **post):
# When skip payment step, the transaction not exists so only render
# the waiting message in ajax json call
if not request.website.checkout_skip_payment:
return super().shop_payment_get_status(sale_order_id, **post)
return {
"recall": True,
"message": request.website._render(
"website_sale_checkout_skip_payment.order_state_message"
),
}
def _get_shop_payment_values(self, order, **kwargs):
values = super()._get_shop_payment_values(order, **kwargs)
partner = values.get("partner")
if partner.skip_website_checkout_payment:
values["hide_payment_button"] = True
return values

@http.route()
def shop_payment_confirmation(self, **post):
Expand All @@ -39,7 +33,5 @@ def shop_payment_confirmation(self, **post):
# This could not finish (e.g.: sale_financial_risk exceeded)
order.action_confirm()
request.website.sale_reset()
return request.render(
"website_sale.confirmation",
{"order": order, "order_tracking_info": self.order_2_return_dict(order)},
)
values = self._prepare_shop_payment_confirmation_values(order)
return request.render("website_sale.confirmation", values)
10 changes: 0 additions & 10 deletions website_sale_checkout_skip_payment/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,3 @@ msgstr "Mensaje de omisión de venta del sitio web"
#: model_terms:ir.ui.view,arch_db:website_sale_checkout_skip_payment.order_state_message
msgid "Your order is waiting manual confirmation."
msgstr "Su pedido está a la espera de confirmación manual."

#~ msgid ""
#~ "<i class=\"fa fa-chevron-left\"/>\n"
#~ " Return to Cart"
#~ msgstr ""
#~ "<i class=\"fa fa-chevron-left\"/>\n"
#~ " Devolver al carrito"

#~ msgid "Confirm <span class=\"fa fa-chevron-right\"/>"
#~ msgstr "Confirmar <span class=\"fa fa-chevron-right\"/>"
4 changes: 2 additions & 2 deletions website_sale_checkout_skip_payment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from . import website
from . import res_partner
from . import res_config_settings
from . import res_partner
from . import website
9 changes: 6 additions & 3 deletions website_sale_checkout_skip_payment/models/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
class Website(models.Model):
_inherit = "website"

def _get_default_skip_message(self):
return _(
"Our team will check your order and send you payment information soon."
)

website_sale_checkout_skip_message = fields.Text(
string="Website Sale SKip Message",
required=True,
translate=True,
default=lambda s: _(
"Our team will check your order and send you payment information soon."
),
default=_get_default_skip_message,
)
checkout_skip_payment = fields.Boolean(compute="_compute_checkout_skip_payment")

Expand Down
1 change: 1 addition & 0 deletions website_sale_checkout_skip_payment/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- David Vidal
- Alexandre Díaz
- Carlos Roca
- Pilar Vargas
- Martin Wilderoth \<<[email protected]>\>
- [Studio73](https://www.studio73.es):
- Miguel Gandia \<<[email protected]>\>
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>David Vidal</li>
<li>Alexandre Díaz</li>
<li>Carlos Roca</li>
<li>Pilar Vargas</li>
</ul>
</li>
<li>Martin Wilderoth &lt;<a class="reference external" href="mailto:martin.wilderoth&#64;linserv.se">martin.wilderoth&#64;linserv.se</a>&gt;</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/** @odoo-module **/

import {registry} from "@web/core/registry";
import * as tourUtils from "@website_sale/js/tours/tour_utils";

registry.category("web_tour.tours").add("website_sale_checkout_skip_payment", {
url: "/shop",
steps: () => [
...tourUtils.searchProduct("Storage Box"),
{
content: "select Storage Box",
trigger: '.oe_product_cart:first a:contains("Storage Box")',
run: "click",
},
{
content: "click on add to cart",
trigger: '#product_detail form[action^="/shop/cart/update"] #add_to_cart',
run: "click",
},
tourUtils.goToCart({quantity: 1}),
tourUtils.goToCheckout(),
tourUtils.confirmOrder(),
{
content: "Confirm order",
trigger: "a.a-submit[href='#']:contains('Confirm')",
run: "click",
},
{
content: "Print order",
trigger: "a[href='/shop/print']",
},
],
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def test_checkout_skip_payment(self):

def test_ui_website(self):
"""Test frontend tour."""
self.start_tour("/shop", "website_sale_checkout_skip_payment", login="admin")
self.start_tour("/", "website_sale_checkout_skip_payment", login="admin")
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,20 @@
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="website.res_config_settings_view_form" />
<field name="inherit_id" ref="website_sale.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath
expr="//div[@id='website_settings']/div[@id='social_default_image_setting']"
position="after"
>
<div class="col-12 o_setting_box" id="sale_checkout_skip_message">
<div class="o_setting_right_pane">
<label
string="Sale Checkout Skip Message"
for="website_sale_checkout_skip_message"
/>
<span
class="fa fa-lg fa-globe"
title="Values set here are website-specific."
groups="website.group_multi_website"
/>
<div class="text-muted">
Message shown to the user when the purchase is finished
<xpath expr="//block[@id='website_shop_checkout']" position="inside">
<setting
id="sale_checkout_skip_message"
string="Sale Checkout Skip Message"
help="Message shown to the user when the purchase is finished"
>
<div class="content-group">
<div class="row">
<field name="website_sale_checkout_skip_message" />
</div>
<field name="website_sale_checkout_skip_message" />
</div>
</div>
</setting>
</xpath>
</field>
</record>
Expand Down
106 changes: 47 additions & 59 deletions website_sale_checkout_skip_payment/views/website_sale_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,30 @@
<!-- Copyright 2017 Sergio Teruel <[email protected]>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<template id="payment" inherit_id="website_sale.payment" priority="25">
<xpath expr="//div[hasclass('js_payment')]" position="after">
<div class="d-flex justify-content-between">
<div class="float-left mt-2" t-if="website.checkout_skip_payment">
<a role="button" href="/shop/cart" class="btn btn-secondary">
<i class="fa fa-chevron-left" />
Return to Cart
</a>
</div>
<div
class="js_skip_payment mt-3"
t-if="website.checkout_skip_payment"
id="skip_payment_method"
>
<form
target="_self"
action="/shop/confirmation"
method="post"
class="float-right"
>
<input
type="hidden"
name="csrf_token"
t-att-value="request.csrf_token()"
/>
<a role="button" class="btn btn-primary a-submit" href="#">
<span>Confirm <span class="fa fa-chevron-right" /></span>
</a>
</form>
</div>
</div>
</xpath>
<xpath expr="//t[@name='website_sale_non_free_cart']" position="attributes">
<xpath expr="//div[@name='website_sale_non_free_cart']" position="attributes">
<attribute
name="t-if"
separator=" "
add="and not website.checkout_skip_payment"
separator="and"
add="not website.checkout_skip_payment"
/>
</xpath>
<xpath expr="//div[hasclass('js_payment')]" position="attributes">
</template>
<template id="confirmation" inherit_id="website_sale.confirmation">
<xpath
expr='//div[@t-if="tx_sudo.state in [&apos;pending&apos;, &apos;done&apos;]"]'
position="attributes"
>
<attribute
name="t-if"
separator=" "
add="and not website.checkout_skip_payment"
/>
>tx_sudo.state in ['pending', 'done'] or (website.checkout_skip_payment and order.state == 'sale')</attribute>
</xpath>
</template>
<template id="confirmation" inherit_id="website_sale.confirmation">
<xpath
expr='//t[@t-if="payment_tx_id.state == &apos;done&apos;"]'
expr='//t[@t-if="tx_sudo.state == &apos;done&apos;"]'
position="attributes"
>
<attribute
name="t-if"
>payment_tx_id.state == 'done' or (website.checkout_skip_payment and order.state == 'sale')</attribute>
>tx_sudo.state == 'done' or website.checkout_skip_payment</attribute>
</xpath>
<xpath
expr="//t[@t-call='website_sale.payment_confirmation_status']"
Expand All @@ -78,27 +48,45 @@
<attribute name="t-if">not website.checkout_skip_payment</attribute>
</xpath>
</template>
<template id="order_state_message">
<p>Your order is waiting manual confirmation.</p>
<br />
</template>
<template id="cart" inherit_id="website_sale.cart">
<xpath expr="//a[hasclass('btn-primary')]//t[2]/span[1]" position="attributes">
<template id="navigation_buttons" inherit_id="website_sale.navigation_buttons">
<xpath expr="//a[@name='website_sale_main_button']/t" position="attributes">
<attribute name="t-if">not website.checkout_skip_payment</attribute>
</xpath>
<xpath expr="//a[hasclass('btn-primary')]//t[2]/span[1]" position="after">
<xpath expr="//a[@name='website_sale_main_button']/t" position="after">
<span t-if="website.checkout_skip_payment">Confirm</span>
</xpath>
</template>
<template id="short_cart_summary" inherit_id="website_sale.short_cart_summary">
<xpath
expr="//a[hasclass('btn-secondary')]//t[2]/span[1]"
position="attributes"
>
<attribute name="t-if">not website.checkout_skip_payment</attribute>
</xpath>
<xpath expr="//a[hasclass('btn-secondary')]//t[2]/span[1]" position="after">
<span t-if="website.checkout_skip_payment">Confirm</span>
<xpath expr="//t[@t-else='']" position="after">
<div
t-if="website.checkout_skip_payment and xmlid == 'website_sale.payment'"
id="skip_payment_method"
>
<form
name="o_wsale_confirm_order"
class="d-flex flex-column"
target="_self"
action="/shop/confirmation"
method="post"
>
<input
type="hidden"
name="csrf_token"
t-att-value="request.csrf_token()"
/>
<a role="button" class="btn btn-primary a-submit" href="#">
<span>Confirm <span
class="fa fa-angle-right ms-2 fw-light"
/></span>
</a>
</form>
</div>
<div
t-if="website.checkout_skip_payment and xmlid == 'website_sale.payment'"
t-attf-class="position-relative #{_form_send_navigation and 'd-flex d-lg-none' or 'd-flex'} w-100 justify-content-center align-items-center my-2 opacity-75"
>
<hr class="w-100" />
<span class="px-3">or</span>
<hr class="w-100" />
</div>
</xpath>
</template>
</odoo>

0 comments on commit ae069c9

Please sign in to comment.