Skip to content

Commit

Permalink
[IMP] website_sale_suggest_login: pre-commit stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
oihane committed Jun 26, 2024
1 parent 50d7513 commit aaf11d4
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 46 deletions.
1 change: 0 additions & 1 deletion website_sale_suggest_login/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

from . import models
10 changes: 5 additions & 5 deletions website_sale_suggest_login/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright 2021 Leire Martinez de Santos - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
'name': "Website Sale Suggest Login",
"name": "Website Sale Suggest Login",
"license": "AGPL-3",
"author": "AvanzOSC",
"website": "http://www.avanzosc.es",
'version': '14.0.1.0.0',
'depends': ['website_sale_suggest_create_account'],
'data': ['views/templates.xml', 'views/views.xml'],
"website": "https://github.com/avanzosc/sale-addons",
"version": "14.0.1.0.0",
"depends": ["website_sale_suggest_create_account"],
"data": ["views/templates.xml", "views/views.xml"],
}
1 change: 0 additions & 1 deletion website_sale_suggest_login/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

from . import res_config
17 changes: 10 additions & 7 deletions website_sale_suggest_login/models/res_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@


class Company(models.Model):
_inherit = 'res.company'
_inherit = "res.company"

website_checkout_redirect = fields.Selection(
selection=[('login', 'Login'),
('create_account', 'Create Account')],
string='Website Checkout Redirect', default='login')
selection=[("login", "Login"), ("create_account", "Create Account")],
string="Website Checkout Redirect",
default="login",
)


class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
_inherit = "res.config.settings"

website_checkout_redirect = fields.Selection(
'Website Checkout Redirect',
related='company_id.website_checkout_redirect', readonly=False)
"Website Checkout Redirect",
related="company_id.website_checkout_redirect",
readonly=False,
)
60 changes: 35 additions & 25 deletions website_sale_suggest_login/views/templates.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="cart" inherit_id="website_sale_suggest_create_account.cart" customize_show="True">
<template
id="cart"
inherit_id="website_sale_suggest_create_account.cart"
customize_show="True"
priority="100"
>
<xpath expr="//a[@t-if='suggest_login']" position="replace">
<a
t-if="suggest_login or request.env.user.company_id.website_checkout_redirect == 'login'"
role="button"
class="btn btn-primary pull-right mb32 d-none d-xl-inline-block"
href="/web/login?redirect=/shop/checkout?express=1"
>
t-if="suggest_login or request.env.user.company_id.website_checkout_redirect == 'login'"
role="button"
class="btn btn-primary pull-right mb32 d-none d-xl-inline-block"
href="/web/login?redirect=/shop/checkout?express=1"
>
<span>Log in and checkout</span>
<span class="fa fa-long-arrow-right" />
</a>
</xpath>
<xpath expr="//t[@t-if='suggest_create_account']" position="replace">
<t t-if="suggest_create_account and request.env.user.company_id.website_checkout_redirect == 'create_account'">
<t
t-if="suggest_create_account and request.env.user.company_id.website_checkout_redirect == 'create_account'"
>
<a
class="btn btn-primary pull-right mb32 d-none d-xl-inline-block"
role="button"
href="/web/signup?redirect=/shop/checkout?express=1"
>
class="btn btn-primary pull-right mb32 d-none d-xl-inline-block"
role="button"
href="/web/signup?redirect=/shop/checkout?express=1"
>
<span>Sign up and checkout</span>
<span class="fa fa-long-arrow-right" />
</a>
Expand All @@ -27,27 +34,30 @@
</template>
<!-- Cart summary -->
<template
id="short_cart_summary"
inherit_id="website_sale_suggest_create_account.short_cart_summary"
customize_show="True"
>
id="short_cart_summary"
inherit_id="website_sale_suggest_create_account.short_cart_summary"
customize_show="True"
priority="100"
>
<xpath expr="//a[@t-if='suggest_login']" position="replace">
<a
t-if="suggest_login or request.env.user.company_id.website_checkout_redirect == 'login'"
role="button"
class="btn btn-secondary float-right d-none d-xl-inline-block"
href="/web/login?redirect=/shop/checkout?express=1"
>
t-if="suggest_login or request.env.user.company_id.website_checkout_redirect == 'login'"
role="button"
class="btn btn-secondary float-right d-none d-xl-inline-block"
href="/web/login?redirect=/shop/checkout?express=1"
>
<span>Log in and checkout</span>
</a>
</xpath>
<xpath expr="//t[@t-if='suggest_create_account']" position="replace">
<t t-if="suggest_create_account and request.env.user.company_id.website_checkout_redirect == 'create_account'">
<t
t-if="suggest_create_account and request.env.user.company_id.website_checkout_redirect == 'create_account'"
>
<a
class="btn btn-secondary float-right d-none d-xl-inline-block"
role="button"
href="/web/signup?redirect=/shop/checkout?express=1"
>
class="btn btn-secondary float-right d-none d-xl-inline-block"
role="button"
href="/web/signup?redirect=/shop/checkout?express=1"
>
<span>Sign up and checkout</span>
</a>
</t>
Expand Down
20 changes: 13 additions & 7 deletions website_sale_suggest_login/views/views.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="model">res.config.settings</field>
<field name="priority" eval="0"/>
<field name="inherit_id" ref="website.res_config_settings_view_form"/>
<field name="priority" eval="0" />
<field name="inherit_id" ref="website.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[hasclass('settings')]//div[@id='website_settings']" position="inside">
<div class="col-6 col-lg-6 o_setting_box" id="portal_login_redirect_setting">
<xpath
expr="//div[hasclass('settings')]//div[@id='website_settings']"
position="inside"
>
<div
class="col-6 col-lg-6 o_setting_box"
id="portal_login_redirect_setting"
>
<div class="o_setting_right_pane">
<label for="website_checkout_redirect"/>
<field name='website_checkout_redirect'/>
<label for="website_checkout_redirect" />
<field name='website_checkout_redirect' />
</div>
</div>
</xpath>
Expand Down

0 comments on commit aaf11d4

Please sign in to comment.