diff --git a/website_hide_button/__init__.py b/website_hide_button/__init__.py index fff2d1872..0ff229d48 100644 --- a/website_hide_button/__init__.py +++ b/website_hide_button/__init__.py @@ -20,3 +20,4 @@ # ############################################################################### from . import controllers +from . import models diff --git a/website_hide_button/__manifest__.py b/website_hide_button/__manifest__.py index ac0819ee9..7713ffff3 100644 --- a/website_hide_button/__manifest__.py +++ b/website_hide_button/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################### { 'name': "Hide Price, Add To Cart And Quantity Button In Website", - 'version': '17.0.1.0.1', + 'version': '17.0.2.0.0', 'category': 'Website', 'summary': """Hide Price, Add To Cart and Quantity button for guest users""", @@ -36,6 +36,7 @@ 'data': [ 'views/product_templates.xml', 'views/shop_templates.xml', + 'views/res_config_settings_views.xml' ], 'images': ['static/description/banner.jpg'], 'license': 'AGPL-3', diff --git a/website_hide_button/controllers/website_sale.py b/website_hide_button/controllers/website_sale.py index b418dcaab..b7364d409 100644 --- a/website_hide_button/controllers/website_sale.py +++ b/website_hide_button/controllers/website_sale.py @@ -40,7 +40,10 @@ class WebsiteSaleInherit(WebsiteSale): res = super().shop(page, category, search, min_price, max_price, ppg, **post) res.qcontext.update({ - 'login_user': False if request.session.uid is None else True + 'login_user': True if not request.env.user._is_public() or ( + request.env.user._is_public() and not request.env[ + 'ir.config_parameter'].sudo().get_param( + 'website_hide_button.hide_cart')) else False, }) return res @@ -50,7 +53,10 @@ class WebsiteSaleInherit(WebsiteSale): category, search, **kwargs) - res['login_user'] = False if request.session.uid is None else True + res['login_user'] = True if not request.env.user._is_public() or ( + request.env.user._is_public() and not request.env[ + 'ir.config_parameter'].sudo().get_param( + 'website_hide_button.hide_cart')) else False return res @http.route() @@ -58,7 +64,12 @@ class WebsiteSaleInherit(WebsiteSale): """ 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 \ + if ( + not user._is_public() or user._is_public() and not request.env.user._is_public() and not + request.env[ + 'ir.config_parameter'].sudo().get_param( + 'website_hide_button.hide_cart')) and user.has_group( + 'base.group_portal') or \ user.has_group('base.group_user'): res = super(WebsiteSaleInherit, self).shop_payment(**post) return res diff --git a/website_hide_button/doc/RELEASE_NOTES.md b/website_hide_button/doc/RELEASE_NOTES.md index de8412f90..af7c2ff56 100644 --- a/website_hide_button/doc/RELEASE_NOTES.md +++ b/website_hide_button/doc/RELEASE_NOTES.md @@ -3,7 +3,11 @@ #### 06.02.2024 #### Version 17.0.1.0.0 #### ADD - - Initial commit for Hide Price, Add To Cart And Quantity Button In Website +#### 23.09.2024 +#### Version 17.0.2.0.0 +##### UPDT +- Bug Fix-Added an option in the general settings of the Website module to enable 'Hide Cart for Guests' and 'Hide Product Prices from Guests'. + diff --git a/website_hide_button/models/__init__.py b/website_hide_button/models/__init__.py new file mode 100644 index 000000000..7eb5a5338 --- /dev/null +++ b/website_hide_button/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Unnimaya C O (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import res_config_settings diff --git a/website_hide_button/models/res_config_settings.py b/website_hide_button/models/res_config_settings.py new file mode 100755 index 000000000..35873ac41 --- /dev/null +++ b/website_hide_button/models/res_config_settings.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Unnimaya C O (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from odoo import api, fields, models + + +class ResConfigSettings(models.TransientModel): + """ + Add extra fields in the settings. + """ + _inherit = 'res.config.settings' + + hide_price = fields.Boolean(string='Hide Price', + config_parameter='website_hide_button.hide_price', + help="If enabled, the price of product will not be visible to guest users in website") + hide_cart = fields.Boolean(string='Hide Cart', + config_parameter='website_hide_button.hide_cart', + help="If enabled, the Add to Cart button and Cart Icon will be visible to guest users") + + def set_values(self): + """Method for setting the parameters""" + super(ResConfigSettings, self).set_values() + self.env['ir.config_parameter'].sudo().set_param( + 'website_hide_button.hide_price', self.hide_price) + self.env['ir.config_parameter'].sudo().set_param( + 'website_hide_button.hide_cart', self.hide_cart) + + @api.model + def get_smartsupp_details(self): + """Method for get value""" + hide_price = self.env['ir.config_parameter'].sudo().get_param( + 'website_hide_button.hide_price') + hide_cart = self.env['ir.config_parameter'].sudo().get_param( + 'website_hide_button.hide_cart') + return { + 'hide_price': hide_price, + 'hide_cart': hide_cart, + } + + @api.onchange('hide_price') + def _onchange_hide_price(self): + if self.hide_price: + self.hide_cart = True diff --git a/website_hide_button/static/description/assets/screenshots/0.png b/website_hide_button/static/description/assets/screenshots/0.png new file mode 100644 index 000000000..75f400c00 Binary files /dev/null and b/website_hide_button/static/description/assets/screenshots/0.png differ diff --git a/website_hide_button/static/description/index.html b/website_hide_button/static/description/index.html index 4b19d431b..f7ea5954c 100644 --- a/website_hide_button/static/description/index.html +++ b/website_hide_button/static/description/index.html @@ -46,8 +46,10 @@ #1A202C;"> Hide Price, Add To Cart And Quantity Button In Website

This App Allows Only Login Users to View the Price, Add To Cart - Button and Quantity from Website. + style="max-width: 80%; font-weight: 400 !important; line-height: 32px; color: #718096;"> + This App Allows Only Login Users to View the Price, Add To + Cart + Button and Quantity from Website.

-
-
-

- Key Highlights -

-
-
-
-
+
+

+ Key Highlights +

+
+
+
+
-
- -
-
-

Hide Price, Add to cart buttons and Quantity of - the product from Guest users. That will be only visible + +

+
+

+ Hide Price, Add to cart buttons and Quantity of + the product from Guest users. That will be only + visible to login users. -

-
-
-
+
+
-
- -
-
-

+

+
+

- Hide cart quickview for public users. -

+ Hide cart quickview for public users.
-
-
-
+
+
-
- -
-
-

+

+
+

- Disable the order creation option for public users. -

+ Disable the order creation option for public + users.
+