Browse Source

Nov 30 : [UPDT] Feature Updated 'website_hide_button'

pull/295/head
RisvanaCybro 2 years ago
parent
commit
c3b1ca9341
  1. 5
      website_hide_button/__manifest__.py
  2. 26
      website_hide_button/controllers/website_sale.py
  3. 6
      website_hide_button/doc/RELEASE_NOTES.md
  4. 13
      website_hide_button/static/description/index.html
  5. 3
      website_hide_button/static/src/css/product_details.css
  6. 102
      website_hide_button/views/product_templates.xml
  7. 2
      website_hide_button/views/shop_templates.xml

5
website_hide_button/__manifest__.py

@ -37,11 +37,6 @@
'views/product_templates.xml',
'views/shop_templates.xml',
],
'assets': {
'web.assets_frontend': [
'website_hide_button/static/src/css/product_details.css'
]
},
'images': ['static/description/banner.jpg'],
'license': 'AGPL-3',
'installable': True,

26
website_hide_button/controllers/website_sale.py

@ -27,11 +27,18 @@ from odoo.addons.website_sale.controllers.main import WebsiteSale
class WebsiteSaleInherit(WebsiteSale):
"""class to hide price, add to cart and quantity"""
@http.route([
'''/shop''',
'''/shop/page/<int:page>''',
'''/shop/category/<model("product.public.category"):category>''',
'''/shop/category/<model("product.public.category"):category>/
page/<int:page>'''
], type='http', auth="public", website=True)
def shop(self, page=0, category=None, search='', min_price=0.0,
max_price=0.0, ppg=False, **post):
"""Method for finding log in user or not in shop page """
res = super().shop(page, category, search, min_price,
max_price, ppg, **post)
res = super().shop(page=0, category=None, search='', min_price=0.0,
max_price=0.0, ppg=False, **post)
res.qcontext.update({
'login_user': False if request.session.uid is None else True
})
@ -43,7 +50,16 @@ class WebsiteSaleInherit(WebsiteSale):
category,
search,
**kwargs)
res.update({
'login_user': False if request.session.uid is None else True
})
res['login_user'] = False if request.session.uid is None else True
return res
@http.route()
def shop_payment(self, **post):
""" Restrict public visitors from accessing payment page so that SO
creation will be disabled """
user = http.request.env.user
if user and user.has_group('base.group_portal') or \
user.has_group('base.group_user'):
res = super(WebsiteSaleInherit, self).shop_payment(**post)
return res
return request.redirect("/")

6
website_hide_button/doc/RELEASE_NOTES.md

@ -5,3 +5,9 @@
#### ADD
- Initial commit for Hide Price, Add To Cart And Quantity Button In Website
#### 24.11.2023
#### Version 16.0.1.0.1
#### UPDATE
- Merged features from website_sale_price_hide v16.0.1.0.0

13
website_hide_button/static/description/index.html

@ -105,6 +105,7 @@
button. But these features will be hidden for guest users.
</div>
</div>
<!-- END OF OVERVIEW SECTION -->
<!-- FEATURES SECTION -->
<div class="d-flex align-items-center"
@ -130,6 +131,18 @@
to login users.</span>
</div>
</div>
<div class="d-flex align-items-center" style="margin-top: 30px; margin-bottom: 30px">
<img src="assets/misc/check-box.png" class="mr-2"/>
<span style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
Hide cart quickview for public users.
</span>
</div>
<div class="d-flex align-items-center" style="margin-top: 30px; margin-bottom: 30px">
<img src="assets/misc/check-box.png" class="mr-2"/>
<span style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
Disable the order creation option for public users.
</span>
</div>
</div>
<!-- END OF FEATURES SECTION -->
<!-- SCREENSHOTS SECTION -->

3
website_hide_button/static/src/css/product_details.css

@ -1,3 +0,0 @@
.button_remove{
display: none !important;
}

102
website_hide_button/views/product_templates.xml

@ -1,15 +1,109 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<odoo>
<!-- Hide Add To Cart Button and quantity selector for public users -->
<template id="product_hide" inherit_id="website_sale.product">
<xpath expr="//a[@id='add_to_cart']" position="before">
<div class="alert alert-info" t-if="user_id._is_public()">
<i class="fa fa-info-circle" />
<span>Please Log in to see price and buy options.</span>
</div>
</xpath>
<xpath expr="//a[@id='add_to_cart']" position="attributes">
<attribute name="t-if">
not user_id._is_public()
</attribute>
</xpath>
</template>
<!-- Hide Add To Cart button for guest users -->
<template id="product" inherit_id="website_sale.product">
<xpath expr="//div[@id='o_wsale_cta_wrapper']" position="attributes">
<attribute name="t-attf-class">{{'button_remove' if not login_user else '' }}</attribute>
<attribute name="t-if">login_user == True</attribute>
</xpath>
</template>
<!-- Hide Product price for guest users -->
<template id="product_price" inherit_id="website_sale.product_price">
<!-- Hide Product price in price_widget -->
<template id="product_price_hide" inherit_id="website_sale.product_price">
<xpath expr="//div[@itemprop='offers']" position="attributes">
<attribute name="t-attf-class">{{'d-none' if not login_user else '' }}</attribute>
<attribute name="t-if">not user_id._is_public()</attribute>
</xpath>
</template>
<!-- Cart_hide -->
<template id="header_cart_link_hide" inherit_id="website_sale.header_cart_link">
<xpath expr="//t[@t-set='show_cart']" position="replace">
<t t-if="not user_id._is_public()">
<t t-set="show_cart" t-value="true"/>
</t>
<t t-else="">
<t t-set="show_cart" t-value="false"/>
</t>
</xpath>
</template>
<!-- Hide details section in search bar for hide price -->
<template id="search_hide" inherit_id="website_sale.search">
<xpath expr="//t[@t-set='display_detail']" position="replace">
<t t-if="not user_id._is_public()">
<t t-set="display_detail" t-valuef="true"/>
</t>
<t t-else="">
<t t-set="display_detail" t-valuef="false"/>
</t>
</xpath>
</template>
<!-- Hide price Filter -->
<template id="filter_products_price_hide" inherit_id="website_sale.filter_products_price">
<xpath expr="//div[@id='o_wsale_price_range_option']" position="attributes">
<attribute name="t-if">
not user_id._is_public()
</attribute>
</xpath>
</template>
<!-- Product Info Page hiding price related attributes -->
<template id="products_item_hide" inherit_id="website_sale.products_item" priority="99">
<xpath expr="//div[@itemprop='offers']" position="attributes">
<attribute name="t-if">
product.product_variant_ids and not user_id._is_public()
</attribute>
</xpath>
<xpath expr="//div[hasclass('o_wsale_product_btn')]" position="attributes">
<attribute name="t-if">
product.product_variant_ids and not user_id._is_public()
</attribute>
</xpath>
</template>
<!-- Hide Quantity selection -->
<template id="product_quantity_hide" inherit_id="website_sale.product_quantity">
<xpath expr="//div[contains(@t-attf-class, 'css_quantity')]" position="attributes">
<attribute name="t-if">
not user_id._is_public()
</attribute>
</xpath>
</template>
<!-- Hide Price in Search box content -->
<template id="website_search_box_hide" inherit_id="website.website_search_box">
<xpath expr="//input[@name='search']" position="attributes">
<attribute name="t-att-data-display-price">website and not user_id._is_public()</attribute>
</xpath>
</template>
<!-- Hide price in Dynamic Product Filter -->
<template id="price_dynamic_filter_template_product_product" inherit_id="website_sale.price_dynamic_filter_template_product_product">
<xpath expr="//span[hasclass('fw-bold')]" position="attributes">
<attribute name="t-if">not user_id._is_public() and not data['website_hide_price']</attribute>
</xpath>
</template>
<!-- Hide extra badge related to price in price tag -->
<template id="badge_extra_price_hide" inherit_id="sale.badge_extra_price">
<xpath expr="//t[@t-name='sale.badge_extra_price']" position="attributes">
<attribute name="t-if">not user_id._is_public()</attribute>
</xpath>
</template>
</odoo>

2
website_hide_button/views/shop_templates.xml

@ -3,7 +3,7 @@
<!-- Hide product price for Guest users -->
<template id="products_item" inherit_id="website_sale.products_item">
<xpath expr="//div[hasclass('product_price')]" position="attributes">
<attribute name="t-if">login_user</attribute>
<attribute name="t-if">login_user == True</attribute>
</xpath>
</template>
</odoo>

Loading…
Cancel
Save