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 30, 2023
1 parent 4dc7c60 commit e580af3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 65 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,12 +12,14 @@ 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",
},
{
trigger: "button:contains('Proceed to Checkout')",
},
// Go to cart
{
trigger: 'a[href="/shop/cart"]',
Expand Down
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 e580af3

Please sign in to comment.