Skip to content

Commit d8fa1a1

Browse files
committed
[MIG] website_sale_require_login: Migration to 17.0
1 parent 44df5a9 commit d8fa1a1

File tree

7 files changed

+44
-86
lines changed

7 files changed

+44
-86
lines changed

website_sale_require_login/__manifest__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
{
44
"name": "Require login to checkout",
55
"summary": "Force users to login for buying",
6-
"version": "14.0.1.0.0",
6+
"version": "17.0.1.0.0",
77
"category": "Website",
88
"website": "https://github.com/OCA/e-commerce",
99
"author": "Tecnativa, " "LasLabs, " "Odoo Community Association (OCA)",
1010
"license": "AGPL-3",
1111
"installable": True,
1212
"depends": ["website_sale_suggest_create_account", "web_tour"],
13-
"data": ["views/website_sale.xml", "views/assets.xml"],
13+
"data": ["views/website_sale.xml"],
14+
"assets": {
15+
"web.assets_tests": [
16+
"website_sale_require_login/static/tests/tours/checkout.esm.js",
17+
],
18+
},
1419
"post_init_hook": "post_init_hook",
1520
}

website_sale_require_login/hooks.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
# Copyright (C) 2020 Alexandre Díaz - Tecnativa S.L.
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3-
from odoo import SUPERUSER_ID, api
43
from odoo.tools import config
54

65

7-
def post_init_hook(cr, registry):
6+
def post_init_hook(env):
87
if config["test_enable"] or config["test_file"]:
9-
with api.Environment.manage():
10-
env = api.Environment(cr, SUPERUSER_ID, {})
11-
env.ref("website_sale_require_login.cart").active = False
12-
env.ref("website_sale_require_login.short_cart_summary").active = False
8+
env.ref("website_sale_require_login.cart").active = False
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/** @odoo-module */
2+
3+
import {registry} from "@web/core/registry";
4+
5+
registry.category("web_tour.tours").add("shop_buy_checkout_required_login_website", {
6+
test: true,
7+
url: "/shop",
8+
steps: () => [
9+
// Shop Page
10+
{
11+
trigger: "td.oe_product a:first",
12+
},
13+
// Product Page
14+
{
15+
trigger: "#add_to_cart",
16+
},
17+
{
18+
trigger: 'a.o_navlink_background.btn[href="/shop/cart"]',
19+
},
20+
{
21+
trigger: '.oe_website_sale:not(a.btn-primary[href^="/shop/checkout"])',
22+
run: function () {
23+
// Check: do nothing
24+
},
25+
},
26+
{
27+
trigger: '.oe_website_sale:not(a.btn-default[href^="/shop/checkout"])',
28+
run: function () {
29+
// Check: do nothing
30+
},
31+
},
32+
// The End
33+
],
34+
});

website_sale_require_login/static/tests/tours/checkout.js

-40
This file was deleted.

website_sale_require_login/tests/test_checkout.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ def test_01_shop_buy(self):
99
current_website = self.env["website"].get_current_website()
1010
current_website.auth_signup_uninvited = "b2b"
1111
self.env.ref("website_sale_require_login.cart").active = True
12-
self.env.ref("website_sale_require_login.short_cart_summary").active = True
1312
self.start_tour("/shop", "shop_buy_checkout_required_login_website")

website_sale_require_login/views/assets.xml

-15
This file was deleted.

website_sale_require_login/views/website_sale.xml

+1-22
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,11 @@
88
priority="20"
99
customize_show="True"
1010
>
11-
<xpath expr="//div[@id='wrap']" position="before">
11+
<xpath expr="//t[@t-set='show_shorter_cart_summary']" position="before">
1212
<t
1313
t-set="hide_checkout_button"
1414
t-value="not (user_authenticated and can_checkout)"
1515
/>
1616
</xpath>
17-
<xpath
18-
expr="//div[hasclass('oe_cart')]//a[@href='/shop/checkout?express=1']"
19-
position="attributes"
20-
>
21-
<attribute name="t-if">not hide_checkout_button</attribute>
22-
</xpath>
23-
<xpath
24-
expr="//div[hasclass('col-12','col-xl-4')]//a[@href='/shop/checkout?express=1']"
25-
position="attributes"
26-
>
27-
<attribute name="t-if">not hide_checkout_button</attribute>
28-
</xpath>
29-
</template>
30-
<template
31-
id="short_cart_summary"
32-
inherit_id="website_sale.short_cart_summary"
33-
customize_show="True"
34-
>
35-
<xpath expr="//a[@href='/shop/checkout?express=1']" position="attributes">
36-
<attribute name="t-if">not hide_checkout_button</attribute>
37-
</xpath>
3817
</template>
3918
</odoo>

0 commit comments

Comments
 (0)