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..6582331d01 100644
--- a/website_sale_require_login/hooks.py
+++ b/website_sale_require_login/hooks.py
@@ -1,12 +1,16 @@
# Copyright (C) 2020 Alexandre Díaz - Tecnativa S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import SUPERUSER_ID, api
from odoo.tools import config
-def post_init_hook(cr, registry):
+def post_init_hook(env):
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
+ cart_ref = env.ref("website_sale_require_login.cart", raise_if_not_found=False)
+ if cart_ref:
+ cart_ref.active = False
+
+ short_cart_summary_ref = env.ref(
+ "website_sale_require_login.short_cart_summary", raise_if_not_found=False
+ )
+ if short_cart_summary_ref:
+ short_cart_summary_ref.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 @@
-
-
-
-
-
-
-
-
diff --git a/website_sale_require_login/views/website_sale.xml b/website_sale_require_login/views/website_sale.xml
index 47a064ba88..f5792a595d 100644
--- a/website_sale_require_login/views/website_sale.xml
+++ b/website_sale_require_login/views/website_sale.xml
@@ -8,32 +8,11 @@
priority="20"
customize_show="True"
>
-
+
-
- not hide_checkout_button
-
-
- not hide_checkout_button
-
-
-
-
- not hide_checkout_button
-