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 edb198d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 42 deletions.
2 changes: 1 addition & 1 deletion 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 Down
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,47 @@
/** @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')",
},
{
trigger: "a[href='/shop/cart']",
extra_trigger: "sup.my_cart_quantity:contains('1')",
},
{
trigger: 'a:contains("Process Checkout")',
},
{
trigger: "a[href='/shop/checkout']",
},
registry.category("web_tour.tours").add("website_sale_require_legal", {
test: true,
url: "/shop",
steps: () => [
...tourUtils.searchProduct("Storage Box"),
{
content: "select Storage Box",
trigger: '.oe_product_cart:first a:contains("Storage Box")',
},
{
content: "click on add to cart",
trigger: '#product_detail form[action^="/shop/cart/update"] #add_to_cart',
},
tourUtils.goToCart(),
tourUtils.goToCheckout(),
// ...tourUtils.searchProduct("Customizable Desk"),
// {
// trigger: '.oe_product_cart a:contains("Customizable")',
// },
// {
// trigger: "#add_to_cart",
// },
// {
// trigger: "button:contains('Proceed to Checkout')",
// },
// {
// trigger: "a[href='/shop/cart']",
// extra_trigger: "sup.my_cart_quantity:contains('1')",
// },
// {
// trigger: 'a:contains("Process Checkout")',
// },
// {
// trigger: "a[href='/shop/checkout']",
// },
// Fill all required fields except legal terms acceptance
{
trigger: 'select[name="country_id"]',
Expand Down Expand Up @@ -67,18 +82,5 @@ odoo.define("website_sale_require_legal.tour", function (require) {
{
trigger: 'button[name="o_payment_submit_button"]',
},
];

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

return {
steps: steps,
};
],
});
10 changes: 8 additions & 2 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 Down

0 comments on commit edb198d

Please sign in to comment.