-
-
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 09eca7a
Showing
9 changed files
with
79 additions
and
120 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
26 changes: 26 additions & 0 deletions
26
...e_checkout_skip_payment/static/tests/tours/website_sale_checkout_skip_payment_tour.esm.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** @odoo-module */ | ||
|
||
import {registry} from "@web/core/registry"; | ||
import tourUtils from "@website_sale/js/tours/tour_utils"; | ||
|
||
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(), | ||
{ | ||
content: "Click Confirm Button", | ||
trigger: "a[name='confirm_order_checkout_skip_payment']", | ||
}, | ||
{ | ||
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')", | ||
}, | ||
], | ||
}); |
47 changes: 0 additions & 47 deletions
47
..._sale_checkout_skip_payment/static/tests/tours/website_sale_checkout_skip_payment_tour.js
This file was deleted.
Oops, something went wrong.
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,12 @@ | |
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 +46,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 +88,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> |