From 1722c67e3d2564f930881df677b6ae4d5f3dd1ec Mon Sep 17 00:00:00 2001 From: Kuat Azimkhan Date: Wed, 2 Oct 2024 11:42:48 +0500 Subject: [PATCH] [MIG] website_sale_require_login: Migration to 17.0 --- website_sale_require_login/__manifest__.py | 9 ++++- website_sale_require_login/hooks.py | 8 ++-- .../static/tests/tours/checkout.esm.js | 34 ++++++++++++++++ .../static/tests/tours/checkout.js | 40 ------------------- .../tests/test_checkout.py | 1 - website_sale_require_login/views/assets.xml | 15 ------- .../views/website_sale.xml | 23 +---------- 7 files changed, 45 insertions(+), 85 deletions(-) create mode 100644 website_sale_require_login/static/tests/tours/checkout.esm.js delete mode 100644 website_sale_require_login/static/tests/tours/checkout.js delete mode 100644 website_sale_require_login/views/assets.xml diff --git a/website_sale_require_login/__manifest__.py b/website_sale_require_login/__manifest__.py index 53cc468338..cc4f500364 100644 --- a/website_sale_require_login/__manifest__.py +++ b/website_sale_require_login/__manifest__.py @@ -3,13 +3,18 @@ { "name": "Require login to checkout", "summary": "Force users to login for buying", - "version": "14.0.1.0.0", + "version": "17.0.1.0.0", "category": "Website", "website": "https://github.com/OCA/e-commerce", "author": "Tecnativa, " "LasLabs, " "Odoo Community Association (OCA)", "license": "AGPL-3", "installable": True, "depends": ["website_sale_suggest_create_account", "web_tour"], - "data": ["views/website_sale.xml", "views/assets.xml"], + "data": ["views/website_sale.xml"], + "assets": { + "web.assets_tests": [ + "website_sale_require_login/static/tests/tours/checkout.esm.js", + ], + }, "post_init_hook": "post_init_hook", } diff --git a/website_sale_require_login/hooks.py b/website_sale_require_login/hooks.py index 950e173877..9ebdf8c5b8 100644 --- a/website_sale_require_login/hooks.py +++ b/website_sale_require_login/hooks.py @@ -4,9 +4,7 @@ from odoo.tools import config -def post_init_hook(cr, registry): +def post_init_hook(cr): if config["test_enable"] or config["test_file"]: - with api.Environment.manage(): - env = api.Environment(cr, SUPERUSER_ID, {}) - env.ref("website_sale_require_login.cart").active = False - env.ref("website_sale_require_login.short_cart_summary").active = False + env = api.Environment(cr, SUPERUSER_ID, {}) + env.ref("website_sale_require_login.cart").active = False diff --git a/website_sale_require_login/static/tests/tours/checkout.esm.js b/website_sale_require_login/static/tests/tours/checkout.esm.js new file mode 100644 index 0000000000..96f9504234 --- /dev/null +++ b/website_sale_require_login/static/tests/tours/checkout.esm.js @@ -0,0 +1,34 @@ +/** @odoo-module */ + +import {registry} from "@web/core/registry"; + +registry.category("web_tour.tours").add("shop_buy_checkout_required_login_website", { + test: true, + url: "/shop", + steps: () => [ + // Shop Page + { + trigger: "td.oe_product a:first", + }, + // Product Page + { + trigger: "#add_to_cart", + }, + { + trigger: 'a.o_navlink_background.btn[href="/shop/cart"]', + }, + { + trigger: '.oe_website_sale:not(a.btn-primary[href^="/shop/checkout"])', + run: function () { + // Check: do nothing + }, + }, + { + trigger: '.oe_website_sale:not(a.btn-default[href^="/shop/checkout"])', + run: function () { + // Check: do nothing + }, + }, + // The End + ], +}); diff --git a/website_sale_require_login/static/tests/tours/checkout.js b/website_sale_require_login/static/tests/tours/checkout.js deleted file mode 100644 index a9e03632e9..0000000000 --- a/website_sale_require_login/static/tests/tours/checkout.js +++ /dev/null @@ -1,40 +0,0 @@ -odoo.define("wbesite_sale_require_login.shop_buy", function (require) { - "use strict"; - - var tour = require("web_tour.tour"); - - tour.register( - "shop_buy_checkout_required_login_website", - { - test: true, - url: "/shop", - }, - [ - // Shop Page - { - trigger: "td.oe_product a:first", - }, - // Product Page - { - trigger: "#add_to_cart", - }, - { - trigger: 'a[href="/shop/cart"]', - extra_trigger: "sup.my_cart_quantity:contains('1')", - }, - { - trigger: '.oe_website_sale:not(a.btn-primary[href^="/shop/checkout"])', - run: function () { - // Check: do nothing - }, - }, - { - trigger: '.oe_website_sale:not(a.btn-default[href^="/shop/checkout"])', - run: function () { - // Check: do nothing - }, - }, - // The End - ] - ); -}); diff --git a/website_sale_require_login/tests/test_checkout.py b/website_sale_require_login/tests/test_checkout.py index 7f182be7e4..d18c953450 100644 --- a/website_sale_require_login/tests/test_checkout.py +++ b/website_sale_require_login/tests/test_checkout.py @@ -9,5 +9,4 @@ def test_01_shop_buy(self): current_website = self.env["website"].get_current_website() current_website.auth_signup_uninvited = "b2b" self.env.ref("website_sale_require_login.cart").active = True - self.env.ref("website_sale_require_login.short_cart_summary").active = True self.start_tour("/shop", "shop_buy_checkout_required_login_website") diff --git a/website_sale_require_login/views/assets.xml b/website_sale_require_login/views/assets.xml deleted file mode 100644 index 8d58dc2158..0000000000 --- a/website_sale_require_login/views/assets.xml +++ /dev/null @@ -1,15 +0,0 @@ - - -