diff --git a/product_visibility_website/__manifest__.py b/product_visibility_website/__manifest__.py index 5b3a350e8..83a3b98a3 100644 --- a/product_visibility_website/__manifest__.py +++ b/product_visibility_website/__manifest__.py @@ -22,7 +22,7 @@ ################################################################################ { 'name': 'Website Product Visibility', - 'version': '16.0.1.1.1', + 'version': '16.0.1.1.2', 'category': 'Website', 'summary': 'Website Product visibility for Users', 'description': """Website Product visibility for Users""", @@ -35,7 +35,7 @@ 'views/website_product_visibility.xml', 'views/res_config_settings_views.xml' ], - 'images': ['static/description/1.png'], + 'images': ['static/description/banner.png'], 'license': 'AGPL-3', 'installable': True, 'auto_install': False, diff --git a/product_visibility_website/controllers/main.py b/product_visibility_website/controllers/main.py index 5d436c5c0..eab20d277 100644 --- a/product_visibility_website/controllers/main.py +++ b/product_visibility_website/controllers/main.py @@ -357,123 +357,3 @@ class ProductVisibilityCon(WebsiteSale): partner = request.env['res.partner'].sudo().search( [('id', '=', user.partner_id.id)]) return partner.website_available_product_ids - - # -------------------------------------------------------------------------- - # Products Search Bar - # -------------------------------------------------------------------------- - - @http.route('/shop/products/autocomplete', type='json', auth='public', - website=True) - def products_autocomplete(self, term, options={}, **kwargs): - """ - Returns list of products according to the term and product options - Params: - term (str): search term written by the user - options (dict) - - 'limit' (int), default to 5: number of products to consider - - 'display_description' (bool), default to True - - 'display_price' (bool), default to True - - 'order' (str) - - 'max_nb_chars' (int): max number of characters for the - description if returned - Returns: - dict (or False if no result) - - 'products' (list): products (only their needed field values) - note: the prices will be strings properly formatted and - already containing the currency - - 'products_count' (int): the number of products in the database - that matched the search query - """ - user = request.env['res.users'].sudo().search( - [('id', '=', request.env.user.id)]) - available_categ = available_products = '' - if not user: - mode = request.env['ir.config_parameter'].sudo().get_param( - 'filter_mode') - products = literal_eval( - request.env['ir.config_parameter'].sudo().get_param( - 'website_product_visibility.' - 'available_products_for_guest_ids', 'False')) - if mode == 'product_only': - available_products = request.env['product.template'].search( - [('id', 'in', products)]) - cat = literal_eval( - request.env['ir.config_parameter'].sudo().get_param( - 'website_product_visibility.available_cat_for_guest_ids', - 'False')) - available_categ = request.env['product.public.category'].search( - [('id', 'in', cat)]) - else: - partner = request.env['res.partner'].sudo().search( - [('id', '=', user.partner_id.id)]) - mode = partner.filter_mode - if mode != 'categ_only': - available_products = self.available_products() - available_categ = partner.website_available_cat_ids - ProductTemplate = request.env['product.template'] - display_description = options.get('display_description', True) - display_price = options.get('display_price', True) - order = self._get_search_order(options) - max_nb_chars = options.get('max_nb_chars', 999) - category = options.get('category') - attrib_values = options.get('attrib_values') - if not available_categ and not available_products \ - and request.env.user.has_group( - 'base.group_portal'): - mode = request.env['ir.config_parameter'].sudo().get_param( - 'filter_mode_portal') - products = literal_eval( - request.env['ir.config_parameter'].sudo().get_param( - 'website_product_visibility.' - 'available_products_for_portal_ids', 'False')) - if mode == 'product_only': - available_products = request.env['product.template'].search( - [('id', 'in', products)]) - cat = literal_eval( - request.env['ir.config_parameter'].sudo().get_param( - 'website_product_visibility.available_cat_for_portal_ids', - 'False')) - available_categ = request.env['product.public.category'].search( - [('id', 'in', cat)]) - if not available_products and not available_categ \ - and not request.env.user.has_group( - 'base.group_portal'): - domain = self._get_search_domain(term, category, attrib_values, - display_description) - else: - domain = self.reset_domain(term, available_categ, - available_products, attrib_values, - display_description) - products = ProductTemplate.search( - domain, - limit=min(20, options.get('limit', 5)), - order=order - ) - fields = ['id', 'name', 'website_url'] - if display_description: - fields.append('description_sale') - res = { - 'products': products.read(fields), - 'products_count': ProductTemplate.search_count(domain), - } - if display_description: - for res_product in res['products']: - desc = res_product['description_sale'] - if desc and len(desc) > max_nb_chars: - res_product['description_sale'] = "%s..." % desc[:( - max_nb_chars - 3)] - if display_price: - FieldMonetary = request.env['ir.qweb.field.monetary'] - monetary_options = { - 'display_currency': - request.website.get_current_pricelist().currency_id, - } - for res_product, product in zip(res['products'], products): - combination_info = product._get_combination_info( - only_template=True) - res_product.update(combination_info) - res_product['list_price'] = FieldMonetary.value_to_html( - res_product['list_price'], monetary_options) - res_product['price'] = FieldMonetary.value_to_html( - res_product['price'], monetary_options) - return res diff --git a/product_visibility_website/doc/RELEASE_NOTES.md b/product_visibility_website/doc/RELEASE_NOTES.md index 099d9349c..4e184ac2b 100644 --- a/product_visibility_website/doc/RELEASE_NOTES.md +++ b/product_visibility_website/doc/RELEASE_NOTES.md @@ -13,3 +13,8 @@ #### Version 16.0.1.1.1 ##### FIX - Feature Of Website Product Visibility For Portal Users Is Added + +#### 17.10.2023 +#### Version 16.0.1.1.2 +##### FIX +- The issue with the product/product-category search functionality has been fixed diff --git a/product_visibility_website/models/__init__.py b/product_visibility_website/models/__init__.py index 07a034e53..fb674f590 100644 --- a/product_visibility_website/models/__init__.py +++ b/product_visibility_website/models/__init__.py @@ -20,5 +20,6 @@ # along with this program. If not, see . # ################################################################################ +from . import website from . import res_config_settings from . import website_product_visibility diff --git a/product_visibility_website/models/website.py b/product_visibility_website/models/website.py new file mode 100644 index 000000000..933587c47 --- /dev/null +++ b/product_visibility_website/models/website.py @@ -0,0 +1,107 @@ +from ast import literal_eval +from odoo import models +from odoo.http import request + + +class Website(models.Model): + """ + Extends the 'website' model to filter product search. + """ + _inherit = "website" + _description = "Website" + + def _search_with_fuzzy(self, search_type, search, limit, order, options): + """ + This method extends the base search functionality to include additional + filtering + """ + res = super()._search_with_fuzzy( + search_type, search, limit, order, options) + response = list(res) + available_products = False + user = request.env['res.users'].sudo().search( + [('id', '=', request.env.user.id)]) + if response[1][0] and (response[1][0].get( + 'model', '') == 'product.template' or response[1][0].get( + 'model', '') == 'product.public.category'): + if not user: + mode = request.env['ir.config_parameter'].sudo().get_param( + 'filter_mode') + products = literal_eval( + request.env['ir.config_parameter'].sudo().get_param( + 'website_product_visibility.' + 'available_products_for_guest_ids', 'False')) + if mode == 'product_only': + available_products = request.env['product.template'].search( + [('id', 'in', products)]) + cat = literal_eval( + request.env['ir.config_parameter'].sudo().get_param( + 'website_product_visibility.available_cat_for_guest_ids', + 'False')) + available_categ = request.env['product.public.category'].search( + [('id', 'in', cat)]) + else: + partner = request.env['res.partner'].sudo().search( + [('id', '=', user.partner_id.id)]) + mode = partner.filter_mode + if mode == 'product_only': + available_products = self.available_products() + available_categ = partner.website_available_cat_ids + Category_avail = [] + Category = request.env['product.public.category'] + for ids in available_categ: + if not ids.parent_id.id in available_categ.ids: + Category_avail.append(ids.id) + categ = request.env['product.public.category'].search( + [('id', 'in', Category_avail)]) + if mode == 'product_only': + categ = Category.search([('parent_id', '=', False), ( + 'product_tmpl_ids', 'in', available_products.ids)]) + # supering shop*** + if not available_categ and not available_products and \ + request.env.user.has_group( + 'base.group_portal'): + mode = request.env['ir.config_parameter'].sudo().get_param( + 'filter_mode_portal') + products = literal_eval( + request.env['ir.config_parameter'].sudo().get_param( + 'website_product_visibility.' + 'available_products_for_portal_ids', 'False')) + if mode == 'product_only': + available_products = request.env['product.template'].search( + [('id', 'in', products)]) + cat = literal_eval( + request.env['ir.config_parameter'].sudo().get_param( + 'website_product_visibility.available_cat_for_portal_ids', + 'False')) + available_categ = request.env['product.public.category'].search( + [('id', 'in', cat)]) + if available_products: + product_category = available_products.mapped('public_categ_ids') + category = set(response[1][0]['results'].ids).intersection(set( + product_category.ids)) + products = set(response[1][-1]['results'].ids).intersection(set( + available_products.ids)) + response[1][-1]['results'] = request.env[ + 'product.template'].browse(products) + response[1][0]['results'] = request.env[ + 'product.public.category'].browse(category) + if available_categ: + categ_products = available_categ.mapped('product_tmpl_ids') + products = set(response[1][-1]['results'].ids).intersection(set( + categ_products.ids)) + category = set(response[1][0]['results'].ids).intersection(set( + available_categ.ids)) + response[1][0]['results'] = request.env[ + 'product.public.category'].browse(category) + response[1][-1]['results'] = request.env[ + 'product.template'].browse(products) + return tuple(response) + + def available_products(self): + """Returns the available product (product.template) ids""" + user = request.env['res.users'].sudo().search( + [('id', '=', request.env.user.id)]) + partner = request.env['res.partner'].sudo().search( + [('id', '=', user.partner_id.id)]) + return partner.website_available_product_ids diff --git a/product_visibility_website/static/description/assets/modules/1.png b/product_visibility_website/static/description/assets/modules/1.png index 5238bdeab..e90228872 100644 Binary files a/product_visibility_website/static/description/assets/modules/1.png and b/product_visibility_website/static/description/assets/modules/1.png differ diff --git a/product_visibility_website/static/description/assets/modules/2.png b/product_visibility_website/static/description/assets/modules/2.png index 1ae7cfe3b..7b32f3698 100644 Binary files a/product_visibility_website/static/description/assets/modules/2.png and b/product_visibility_website/static/description/assets/modules/2.png differ diff --git a/product_visibility_website/static/description/assets/modules/3.png b/product_visibility_website/static/description/assets/modules/3.png index 3c3ff1afb..6058f6c3b 100644 Binary files a/product_visibility_website/static/description/assets/modules/3.png and b/product_visibility_website/static/description/assets/modules/3.png differ diff --git a/product_visibility_website/static/description/assets/modules/4.png b/product_visibility_website/static/description/assets/modules/4.png index 3fae4631e..7a9d3b1f6 100644 Binary files a/product_visibility_website/static/description/assets/modules/4.png and b/product_visibility_website/static/description/assets/modules/4.png differ diff --git a/product_visibility_website/static/description/assets/modules/5.gif b/product_visibility_website/static/description/assets/modules/5.gif deleted file mode 100644 index 2a5f8e659..000000000 Binary files a/product_visibility_website/static/description/assets/modules/5.gif and /dev/null differ diff --git a/product_visibility_website/static/description/assets/modules/5.png b/product_visibility_website/static/description/assets/modules/5.png new file mode 100755 index 000000000..2b7aaa6d2 Binary files /dev/null and b/product_visibility_website/static/description/assets/modules/5.png differ diff --git a/product_visibility_website/static/description/assets/modules/6.png b/product_visibility_website/static/description/assets/modules/6.png index 7f2815273..80f8587fb 100644 Binary files a/product_visibility_website/static/description/assets/modules/6.png and b/product_visibility_website/static/description/assets/modules/6.png differ diff --git a/product_visibility_website/static/description/index.html b/product_visibility_website/static/description/index.html index ec5764098..88f281f96 100644 --- a/product_visibility_website/static/description/index.html +++ b/product_visibility_website/static/description/index.html @@ -1,35 +1,43 @@ -
+
-
+
-
+
Community
-
+
Enterprise
-
+
Odoo.sh
+
+
+
+ +

+ Website Product Visibility

+

+ Website Product Visibility For Logged in, Logged out Users/Visitors and Portal Users

+ + +
+
+
- -

- Website Product Visibility

-

- Website Product visibility for logged in and logged out - users/Visitors

- -
@@ -52,10 +60,9 @@ style="background-color: #f5f5f5; padding: 30px; width: 100%;">
Overview - Learn - more about this - module + Learn + more about this + module
@@ -67,10 +74,9 @@ style="background-color: #f5f5f5; padding: 30px; width: 100%;">
Features - View - features of this - module + View + features of this + module
@@ -82,10 +88,9 @@ style="background-color: #f5f5f5; padding: 30px; width: 100%;">
Screenshots - See - key screenshots of this module - + View + screenshots for this + module
@@ -96,7 +101,8 @@
+ style="border-bottom: 2px solid #714B67; padding: 15px 0px;" + id="overview">
@@ -110,7 +116,7 @@ style="font-family: 'Montserrat', sans-serif; font-weight: 400; font-size: 14px; line-height: 200%;">
This module helps you to make visible only the filtered products and - product categories for a logged in and logged out users/visitors. + product categories for a logged in logged out users/visitors and Portal Users. Also, it enables the user to search products and product categories only from those available products and categories.
@@ -132,31 +138,36 @@
-
- - Filter according to the logged users -

- Filter product and product categories according to the logged - user.

+ +
+ Filter according to the logged users +

+ Filter product and product categories according to the logged user.

+ +
-
- - Filter according to the public users/visitors -

- Filter product and product categories according to the public - users/visitors.

+ +
+ Filter according to the public users/visitors and portal users +

Filter product and product categories according to the public users/visitors and portal users.

+ +
-
- - Restrict user searches to available product/category only -

- User can only search product and category among from the - available product/category.

+ +
+ Restrict user searches to available product/category only +

User can only search product and category among from the available product/category.

+ +
+
@@ -195,122 +206,107 @@

Product wise visibility for website shop (Product wise)

-

- Product visibility (Product wise) for the logged user in website - shop.

+

Product visibility (Product wise) for the logged user in website shop.

+

Category wise filtering for website shop (Logged in Users)

-

- Category wise filtering mode for logged user in website - shop.

+

Category wise filtering mode for logged user in website shop.

+

Product visibility for website shop (Category wise)

-

- Product visibility (Category wise) for the logged user in - website shop.

+

Product visibility (Category wise) for the logged user in website shop.

-
+ +

Product wise filtering for website shop (Portal Users)

-

- Product wise filtering mode for the portal users in the website - shop.

+

Product wise filtering mode for the portal users in the website shop.

-
+ +

Set filter for a portal user

-

- Setting the filtering mode for a portal user as No Filter.

+

Setting the filtering mode for a portal user as No Filter.

-
+ +

- Product wise visibility for website shop (Portal Users)

-

- Product visibility (Product wise) for the portal users in + Product wise visibility for website shop (Portal Users) +

Product visibility (Product wise) for the portal users in website shop when no filter is set for them.

-
+ +

Category wise filtering for website shop (Portal Users)

-

- Category wise filtering mode for the portal users in the website +

Category wise filtering mode for the portal users in the website shop.

-
+ +

- Product visibility for website shop portal users (Category - wise)

-

- Product visibility (Category wise) for the portal users in + Product visibility for website shop portal users (Categorywise) +

Product visibility (Category wise) for the portal users in website shop when no filter is set for them.

+

Product wise filtering for website shop (Visitors)

-

- Product wise filtering mode for the visitors in the website - shop.

+

Product wise filtering mode for the visitors in the website shop.

+

Product wise visibility for website shop (Visitors)

-

- Product visibility (Product wise) for the visitors in website - shop.

+

Product visibility (Product wise) for the visitors in website shop.

+

Category wise filtering for website shop (Visitors)

-

- Category wise filtering mode for the visitors in the website - shop.

+

Category wise filtering mode for the visitors in the website shop

+

- Product visibility for website shop visitors (Category - wise)

-

- Product visibility (Category wise) for the visitors in website - shop.

+ Product visibility for website shop visitors (Category wise) +

Product visibility (Category wise) for the visitors in website shop.

+

Search available product from the list

-

- Search product from the available product list.

+

Search product from the available product list.

-
-
+
- + style="background-color: #F5F5F5; border-radius: 0px; width: 40px; height: 40px;"> +
-

- Related +

Related Products

@@ -320,89 +316,65 @@