Skip to content

Commit

Permalink
[MIG] website_sale_require_legal: Migration to version 17.0
Browse files Browse the repository at this point in the history
TT51564
  • Loading branch information
pilarvargas-tecnativa committed Nov 20, 2024
1 parent 65372b1 commit 5f62480
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 49 deletions.
4 changes: 2 additions & 2 deletions website_sale_require_legal/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Require accepting legal terms to checkout",
"summary": "Force the user to accept legal tems to buy in the web shop",
"version": "16.0.1.0.1",
"version": "17.0.1.0.0",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand All @@ -19,7 +19,7 @@
"/website_sale_require_legal/static/src/scss/website_sale_require_legal.scss",
],
"web.assets_tests": [
"/website_sale_require_legal/static/tests/tours/tour.js",
"/website_sale_require_legal/static/tests/tours/tour.esm.js",
],
},
}
4 changes: 3 additions & 1 deletion website_sale_require_legal/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def shop_payment_transaction(self, order_id, access_token, **kwargs):
"""
result = super().shop_payment_transaction(order_id, access_token, **kwargs)
# If the "Accept Terms & Conditions" view is disabled, we log nothing
if not request.website.viewref("website_sale.payment_sale_note").active:
if not request.website.viewref(
"website_sale.accept_terms_and_conditions"
).active:
return result
# Retrieve the sale order
if order_id:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
/** @odoo-module */

/* Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
* Copyright 2023 Pilar Vargas <pilar.vargas@tecnativa.com>
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */

odoo.define("website_sale_require_legal.tour", function (require) {
"use strict";

var tour = require("web_tour.tour");
import {registry} from "@web/core/registry";
import tourUtils from "@website_sale/js/tours/tour_utils";

var steps = [
{
trigger: '.oe_product_cart a:contains("Customizable")',
},
{
trigger: "#add_to_cart",
},
{
trigger: "button:contains('Proceed to Checkout')",
},
registry.category("web_tour.tours").add("website_sale_require_legal", {
test: true,
url: "/shop",
steps: () => [
...tourUtils.searchProduct("Customizable Desk"),
{
trigger: "a[href='/shop/cart']",
extra_trigger: "sup.my_cart_quantity:contains('1')",
content: "select Customizable Desk",
trigger: '.oe_product_cart:first a:contains("Customizable Desk")',
},
{
trigger: 'a:contains("Process Checkout")',
},
{
trigger: "a[href='/shop/checkout']",
content: "click on add to cart",
trigger: '#product_detail form[action^="/shop/cart/update"] #add_to_cart',
},
tourUtils.goToCart(),
tourUtils.goToCheckout(),
// Fill all required fields except legal terms acceptance
{
trigger: 'select[name="country_id"]',
Expand All @@ -42,43 +37,29 @@ odoo.define("website_sale_require_legal.tour", function (require) {
},
// Submit, to prove that it is not possible to continue without accepting the legal terms
{
trigger: ".btn-primary:contains('Next')",
trigger: ".btn-primary:contains('Save address')",
},
// Accept legal terms and accept again
// // Accept legal terms and accept again
{
trigger: "#accepted_legal_terms.is-invalid",
},
{
trigger: ".btn-primary:contains('Next')",
trigger: ".btn-primary:contains('Save address')",
},
{
trigger: "a[href='/shop/confirm_order']",
},
// If I can proceed to payment, it's because the form validated fine
{
trigger: "div[name='o_checkbox_container'] input",
},
{
trigger: ".btn-primary:contains('Pay Now')",
content: "Select `Wire Transfer` payment method",
trigger:
'input[name="o_payment_radio"][data-payment-method-code="dummy_method"]',
},
{
trigger: '#payment_method label:contains("Dummy Provider")',
trigger: "input[id='website_sale_tc_checkbox']",
},
{
trigger: 'button[name="o_payment_submit_button"]',
trigger: 'button[name="o_payment_submit_button"]:visible:not(:disabled)',
},
];

tour.register(
"website_sale_require_legal",
{
url: "/shop",
test: true,
},
steps
);

return {
steps: steps,
};
],
});
23 changes: 20 additions & 3 deletions website_sale_require_legal/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ def setUp(self):
website.viewref(
"website_sale_require_legal.address_require_legal"
).active = True
website.viewref("website_sale.payment_sale_note").active = True
new_test_user(self.env, login="super_mario", groups="base.group_portal")
website.viewref("website_sale.accept_terms_and_conditions").active = True
new_test_user(
self.env,
login="super_mario",
groups="base.group_portal",
password="super_mario",
name="Super Mario",
)
# Create a dummy payment provider to ensure that the tour has at least one
# available to it.
arch = """
Expand All @@ -60,10 +66,21 @@ def setUp(self):
"redirect_form_view_id": redirect_form.id,
}
)
self.dummy_payment_method = self.env["payment.method"].create(
{
"name": "Dummy Payment Method",
"code": "dummy_method",
"support_tokenization": True,
"active": True,
"provider_ids": [(4, self.dummy_provider.id)],
}
)

def test_ui_website(self):
"""Test frontend tour."""
self.start_tour("/shop", "website_sale_require_legal", login="super_mario")
self.start_tour(
"/shop", "website_sale_require_legal", stepDelay=1000, login="super_mario"
)
order = self.env["sale.order"].search(
[
("partner_id", "ilike", "super_mario"),
Expand Down

0 comments on commit 5f62480

Please sign in to comment.