diff --git a/website_sale_require_legal/__manifest__.py b/website_sale_require_legal/__manifest__.py index f54e91c2db..bbb3b73fa0 100644 --- a/website_sale_require_legal/__manifest__.py +++ b/website_sale_require_legal/__manifest__.py @@ -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)", @@ -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", ], }, } diff --git a/website_sale_require_legal/controllers/main.py b/website_sale_require_legal/controllers/main.py index a5c5381047..37c962bcf4 100644 --- a/website_sale_require_legal/controllers/main.py +++ b/website_sale_require_legal/controllers/main.py @@ -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: diff --git a/website_sale_require_legal/static/tests/tours/tour.esm.js b/website_sale_require_legal/static/tests/tours/tour.esm.js new file mode 100644 index 0000000000..de86df8283 --- /dev/null +++ b/website_sale_require_legal/static/tests/tours/tour.esm.js @@ -0,0 +1,103 @@ +/** @odoo-module */ + +/* Copyright 2017 Jairo Llopis + * Copyright 2023 Pilar Vargas + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ + +import {registry} from "@web/core/registry"; +import tourUtils from "@website_sale/js/tours/tour_utils"; + +registry.category("web_tour.tours").add("website_sale_require_legal_with_payment", { + 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(), + // Fill all required fields except legal terms acceptance + { + trigger: 'select[name="country_id"]', + run: function () { + $('input[name="phone"]').val("99999999"); + // Required for test compatibility with the website_sale_vat_required module + $('input[name="vat"]').val("00000000X"); + $('input[name="street"]').val("Castle St., 1"); + $('input[name="city"]').val("Mushroom Kingdom"); + $('input[name="zip"]').val("10000"); + $("#country_id option:eq(1)").attr("selected", true); + }, + }, + // Submit, to prove that it is not possible to continue without accepting the legal terms + { + trigger: ".btn-primary:contains('Save address')", + }, + // // Accept legal terms and accept again + { + trigger: "#accepted_legal_terms.is-invalid", + }, + { + 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: "input[id='website_sale_tc_checkbox']", + }, + ...tourUtils.payWithTransfer(true), + ], +}); + +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(), + // Fill all required fields except legal terms acceptance + { + trigger: 'select[name="country_id"]', + run: function () { + $('input[name="phone"]').val("99999999"); + // Required for test compatibility with the website_sale_vat_required module + $('input[name="vat"]').val("00000000X"); + $('input[name="street"]').val("Castle St., 1"); + $('input[name="city"]').val("Mushroom Kingdom"); + $('input[name="zip"]').val("10000"); + $("#country_id option:eq(1)").attr("selected", true); + }, + }, + // Submit, to prove that it is not possible to continue without accepting the legal terms + { + trigger: ".btn-primary:contains('Save address')", + }, + // // Accept legal terms and accept again + { + trigger: "#accepted_legal_terms.is-invalid", + }, + { + trigger: ".btn-primary:contains('Save address')", + }, + { + trigger: "a[href='/shop/confirm_order']", + }, + ], +}); diff --git a/website_sale_require_legal/static/tests/tours/tour.js b/website_sale_require_legal/static/tests/tours/tour.js deleted file mode 100644 index 0f251334ce..0000000000 --- a/website_sale_require_legal/static/tests/tours/tour.js +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright 2017 Jairo Llopis - * Copyright 2023 Pilar Vargas - * 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"); - - 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']", - }, - // Fill all required fields except legal terms acceptance - { - trigger: 'select[name="country_id"]', - run: function () { - $('input[name="phone"]').val("99999999"); - // Required for test compatibility with the website_sale_vat_required module - $('input[name="vat"]').val("00000000X"); - $('input[name="street"]').val("Castle St., 1"); - $('input[name="city"]').val("Mushroom Kingdom"); - $('input[name="zip"]').val("10000"); - $("#country_id option:eq(1)").attr("selected", true); - }, - }, - // Submit, to prove that it is not possible to continue without accepting the legal terms - { - trigger: ".btn-primary:contains('Next')", - }, - // Accept legal terms and accept again - { - trigger: "#accepted_legal_terms.is-invalid", - }, - { - trigger: ".btn-primary:contains('Next')", - }, - { - 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')", - }, - { - trigger: '#payment_method label:contains("Dummy Provider")', - }, - { - trigger: 'button[name="o_payment_submit_button"]', - }, - ]; - - tour.register( - "website_sale_require_legal", - { - url: "/shop", - test: true, - }, - steps - ); - - return { - steps: steps, - }; -}); diff --git a/website_sale_require_legal/templates/website_sale.xml b/website_sale_require_legal/templates/website_sale.xml index 972e00d7bd..0ba6474643 100644 --- a/website_sale_require_legal/templates/website_sale.xml +++ b/website_sale_require_legal/templates/website_sale.xml @@ -6,7 +6,7 @@