-
-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] website_sale_checkout_skip_payment: Migration to 17.0
- Loading branch information
1 parent
a30bcf0
commit 3fc3566
Showing
8 changed files
with
69 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,25 +2,19 @@ | |
# Copyright 2017 David Vidal <[email protected]> | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import http | ||
from odoo import SUPERUSER_ID, http | ||
from odoo.http import request | ||
|
||
from odoo.addons.website_sale.controllers.main import WebsiteSale | ||
|
||
|
||
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): | ||
|
@@ -31,15 +25,13 @@ def shop_payment_confirmation(self, **post): | |
return super().shop_payment_confirmation(**post) | ||
order = request.env["sale.order"].sudo().browse(order_id) | ||
try: | ||
order.with_context(mark_so_as_sent=True)._send_order_confirmation_mail() | ||
order.with_context(send_email=True, mark_so_as_sent=True).with_user( | ||
SUPERUSER_ID | ||
).action_confirm() | ||
except Exception: | ||
return request.render( | ||
"website_sale_checkout_skip_payment.confirmation_order_error" | ||
) | ||
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
- Martin Wilderoth \<<[email protected]>\> | ||
- [Studio73](https://www.studio73.es): | ||
- Miguel Gandia \<<[email protected]>\> | ||
- Alexei Rivera \<<[email protected]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
This module allows to logged users to checkout with no payment step. At | ||
the end of the checkout proccess the quotation is sent to the user email | ||
address and set to *Qoutation Sent* state. | ||
the end of the checkout process the quotation is sent to the user email | ||
address and set to *Quotation Sent* state. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 21 additions & 42 deletions
63
..._sale_checkout_skip_payment/static/tests/tours/website_sale_checkout_skip_payment_tour.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,26 @@ | ||
odoo.define("website_sale_checkout_skip_payment.tour", function (require) { | ||
"use strict"; | ||
/** @odoo-module */ | ||
|
||
var tour = require("web_tour.tour"); | ||
const tourUtils = require("website_sale.tour_utils"); | ||
import {registry} from "@web/core/registry"; | ||
import tourUtils from "@website_sale/js/tours/tour_utils"; | ||
|
||
tour.register( | ||
"website_sale_checkout_skip_payment", | ||
registry.category("web_tour.tours").add("website_sale_checkout_skip_payment", { | ||
test: true, | ||
url: "/shop", | ||
steps: () => [ | ||
...tourUtils.addToCart({ productName: "Storage Box" }), | ||
tourUtils.goToCart({ quantity: 1 }), | ||
tourUtils.goToCheckout(), | ||
{ | ||
test: true, | ||
url: "/shop?search=Storage%20Box", | ||
content: "Click Confirm Button", | ||
trigger: "a[name='confirm_order_checkout_skip_payment']", | ||
}, | ||
[ | ||
{ | ||
content: "select Storage Box", | ||
extra_trigger: ".oe_search_found", | ||
trigger: '.oe_product_cart a:contains("Storage Box")', | ||
}, | ||
{ | ||
content: "Add Storage Box into cart", | ||
trigger: "a:contains(ADD TO CART)", | ||
}, | ||
tourUtils.goToCart(), | ||
{ | ||
content: "go to checkout", | ||
extra_trigger: "#cart_products input.js_quantity:propValue(1)", | ||
trigger: 'a[href*="/shop/checkout"]', | ||
}, | ||
{ | ||
trigger: '.btn-primary:contains("Confirm")', | ||
}, | ||
{ | ||
trigger: ".btn:contains('Confirm')", | ||
extra_trigger: "b:contains('Billing & Shipping:')", | ||
}, | ||
{ | ||
trigger: "a[href='/shop']", | ||
extra_trigger: "strong:contains('Payment Information:')", | ||
}, | ||
{ | ||
content: "Check confirmation and that the cart has been left empty", | ||
trigger: "a:has(.my_cart_quantity:containsExact(0))", | ||
extra_trigger: "strong:contains('Payment Information:')", | ||
}, | ||
] | ||
); | ||
{ | ||
trigger: "h4:contains('Payment Information')", | ||
}, | ||
{ | ||
content: "Check confirmation and that the cart has been left empty", | ||
trigger: "a:has(.my_cart_quantity:containsExact(0))", | ||
extra_trigger: "h4:contains('Payment Information')", | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
<!-- 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"> | ||
<xpath expr="//t[@name='website_sale_non_free_cart']" position="before"> | ||
<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"> | ||
|
@@ -27,7 +27,7 @@ | |
name="csrf_token" | ||
t-att-value="request.csrf_token()" | ||
/> | ||
<a role="button" class="btn btn-primary a-submit" href="#"> | ||
<a role="button" name="confirm_order_checkout_skip_payment" class="btn btn-primary a-submit" href="#"> | ||
<span>Confirm <span class="fa fa-chevron-right" /></span> | ||
</a> | ||
</form> | ||
|
@@ -41,22 +41,23 @@ | |
add="and 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 ['pending', 'done']"]' | ||
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 == 'done'"]' | ||
expr='//t[@t-if="tx_sudo.state == 'done'"]' | ||
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']" | ||
|
@@ -82,23 +83,4 @@ | |
<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"> | ||
<attribute name="t-if">not website.checkout_skip_payment</attribute> | ||
</xpath> | ||
<xpath expr="//a[hasclass('btn-primary')]//t[2]/span[1]" 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> | ||
</template> | ||
</odoo> |