Skip to content

Commit

Permalink
[MIG] website_sale_suggest_create_account: Migration to version 16.0
Browse files Browse the repository at this point in the history
TT44387
  • Loading branch information
pilarvargas-tecnativa committed Aug 31, 2023
1 parent 4dc7c60 commit 070cdb7
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 70 deletions.
2 changes: 1 addition & 1 deletion website_sale_suggest_create_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Suggest to create user account when buying",
"summary": "Suggest users to create an account when buying in the website",
"version": "15.0.1.0.1",
"version": "16.0.1.0.1",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, LasLabs, Odoo Community Association (OCA)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ odoo.define("wbesite_sale_suggest_create_account.shop_buy", function (require) {
[
// Shop Page
{
trigger: "a.o_product_link:first",
trigger: "a:contains('Customizable')",
},
// Product Page
{
trigger: "#add_to_cart",
},
// Go to cart
{
trigger: 'a[href="/shop/cart"]',
extra_trigger: "sup.my_cart_quantity:contains('1')",
trigger: "button:contains('Proceed to Checkout')",
},
// Go to cart
// {
// trigger: 'a[href="/shop/cart"]',
// extra_trigger: "sup.my_cart_quantity:contains('1')",
// },
{
trigger: 'a.btn-secondary[href^="/web/login"]:first',
trigger:
"a.btn-primary[href='/web/login?redirect=/shop/checkout?express=1']",
},
// TODO: Add a step to check that "checkout" button doesn't exists
// Odoo 13.0 initial config doesn't have b2c actived for the website
Expand Down
12 changes: 11 additions & 1 deletion website_sale_suggest_create_account/tests/test_shop_buy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@ def test_01_shop_buy(self):
if not portal_user.partner_id.vat:
portal_user.partner_id.vat = "BE1234567"
current_website = self.env["website"].get_current_website()
current_website.auth_signup_uninvited = "b2b"
current_website.account_on_checkout = "disabled"
self.env.ref("website_sale_suggest_create_account.cart").active = True
self.env.ref(
"website_sale_suggest_create_account.short_cart_summary"
).active = True
if self.env["ir.module.module"]._get("payment_custom").state != "installed":
self.skipTest("Transfer provider is not installed")
transfer_provider = self.env.ref("payment.payment_provider_transfer")
transfer_provider.write(

Check warning on line 23 in website_sale_suggest_create_account/tests/test_shop_buy.py

View check run for this annotation

Codecov / codecov/patch

website_sale_suggest_create_account/tests/test_shop_buy.py#L22-L23

Added lines #L22 - L23 were not covered by tests
{
"state": "enabled",
"is_published": True,
}
)
transfer_provider._transfer_ensure_pending_msg_is_set()
self.start_tour("/shop", "shop_buy_checkout_suggest_account_website")

Check warning on line 30 in website_sale_suggest_create_account/tests/test_shop_buy.py

View check run for this annotation

Codecov / codecov/patch

website_sale_suggest_create_account/tests/test_shop_buy.py#L29-L30

Added lines #L29 - L30 were not covered by tests
108 changes: 46 additions & 62 deletions website_sale_suggest_create_account/views/website_sale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
/>
<t
t-set="can_checkout"
t-value="website_sale_order and
website_sale_order.website_order_line"
t-value="website_sale_order and website_sale_order.website_order_line"
/>
<t
t-set="suggest_create_account"
Expand All @@ -21,75 +20,48 @@
t-value="not user_authenticated and not signup_allowed and can_checkout"
/>
</xpath>
<xpath expr="//a[@t-attf-href='{{redirect_url}}']/.." position="attributes">
<attribute name="class" />
</xpath>
<!-- Show normal "Checkout" button if user is logged in or external login
is disabled -->
<xpath
expr="//div[hasclass('oe_cart')]//a[@href='/shop/checkout?express=1']"
position="attributes"
>
<xpath expr="//a[@t-attf-href='{{redirect_url}}']" position="attributes">
<attribute name="class" />
<attribute
name="t-attf-class"
>#{'btn btn-primary float-right d-none d-xl-inline-block' if user_authenticated else 'btn btn-default float-right d-none d-xl-inline-block'}</attribute>
>#{'btn btn-primary' if user_authenticated or redirect_to_sign_in else 'btn btn-light'}</attribute>
</xpath>
<!-- Show choice in other cases -->
<xpath
expr="//div[hasclass('oe_cart')]//a[@href='/shop/checkout?express=1']"
position="after"
>
<a
t-if="suggest_login"
<xpath expr="//a[@t-attf-href='{{redirect_url}}']" position="before">
<a
t-if="suggest_login and not redirect_to_sign_in"
role="button"
class="btn btn-primary pull-right mb32 d-none d-xl-inline-block"
class="btn btn-primary"
href="/web/login?redirect=/shop/checkout?express=1"
>
<span>Log in and checkout</span>
<span class="fa fa-long-arrow-right" />
</a>
<t t-if="suggest_create_account">
<a
class="btn btn-primary pull-right mb32 d-none d-xl-inline-block"
<span>Log in and checkout</span>
<span class="fa fa-sign-in" />
</a>
<t t-if="suggest_create_account and not redirect_to_sign_in">
<a
class="btn btn-primary"
role="button"
href="/web/signup?redirect=/shop/checkout?express=1"
>
<span>Sign up and checkout</span>
<span class="fa fa-long-arrow-right" />
</a>
</t>
</xpath>
<!-- Buttons for small screens, same modifications as above -->
<xpath
expr="//div[hasclass('col-12','col-xl-4')]//a[@href='/shop/checkout?express=1']"
position="attributes"
>
<attribute name="class" />
<attribute
name="t-attf-class"
>#{'btn btn-primary float-right' if user_authenticated else 'btn btn-default float-right'}</attribute>
</xpath>
<xpath
expr="//div[hasclass('col-12','col-xl-4')]//a[@href='/shop/checkout?express=1']"
position="after"
>
<a
t-if="suggest_login"
role="button"
class="btn btn-primary pull-right mb32 d-xl-none"
href="/web/login?redirect=/shop/checkout?express=1"
>
<span>Log in and checkout</span>
<span class="fa fa-long-arrow-right" />
</a>
<t t-if="suggest_create_account">
<a
class="btn btn-primary pull-right mb32 d-xl-none"
<span>Sign up and checkout</span>
<span class="fa fa-sign-in" />
</a>
</t>
<t t-if="redirect_to_sign_in">
<a
class="btn btn-light"
role="button"
href="/web/signup?redirect=/shop/checkout?express=1"
>
<span>Sign up and checkout</span>
<span class="fa fa-long-arrow-right" />
</a>
</t>
<span>Sign up</span>
<span class="fa fa-sign-in" />
</a>
</t>
</xpath>
</template>
<!-- Cart summary -->
Expand All @@ -98,28 +70,40 @@
inherit_id="website_sale.short_cart_summary"
customize_show="True"
>
<xpath expr="//a[@href='/shop/checkout?express=1']" position="attributes">
<xpath expr="//a[@t-attf-href='{{redirect_url}}']" position="attributes">
<attribute name="class" />
<attribute
name="t-attf-class"
>#{'btn btn-secondary float-right d-none d-xl-inline-block' if user_authenticated else 'btn btn-default float-right d-none d-xl-inline-block'}</attribute>
>#{'btn btn-secondary float-end d-none d-xl-inline-block' if user_authenticated or redirect_to_sign_in else 'btn btn-light float-end d-none d-xl-inline-block'}</attribute>
</xpath>
<xpath expr="//a[@href='/shop/checkout?express=1']" position="after">
<xpath expr="//a[@t-attf-href='{{redirect_url}}']" position="after">
<a
t-if="suggest_login"
t-if="suggest_login and not redirect_to_sign_in"
role="button"
class="btn btn-secondary float-right d-none d-xl-inline-block"
class="btn btn-secondary float-end d-none d-xl-inline-block"
href="/web/login?redirect=/shop/checkout?express=1"
>
<span>Log in and checkout</span>
<span class="fa fa-sign-in" />
</a>
<t t-if="suggest_create_account">
<t t-if="suggest_create_account and not redirect_to_sign_in">
<a
class="btn btn-secondary float-right d-none d-xl-inline-block"
class="btn btn-secondary float-end"
role="button"
href="/web/signup?redirect=/shop/checkout?express=1"
>
<span>Sign up and checkout</span>
<span class="fa fa-sign-in" />
</a>
</t>
<t t-if="redirect_to_sign_in">
<a
class="btn btn-light float-end d-none d-xl-inline-block"
role="button"
href="/web/signup?redirect=/shop/checkout?express=1"
>
<span>Sign up</span>
<span class="fa fa-sign-in" />
</a>
</t>
</xpath>
Expand Down

0 comments on commit 070cdb7

Please sign in to comment.