From 846235f9ca4b26c56b50a1af7ccb2bca12bc9ffb Mon Sep 17 00:00:00 2001 From: luis Date: Tue, 20 Feb 2024 10:27:45 +0100 Subject: [PATCH 1/2] website_search_products: Fix permissions --- .../controllers/controller.py | 37 ++++++--- website_search_products/data/ir_rule.xml | 13 --- .../views/web_templates.xml | 79 +++++++++++-------- 3 files changed, 71 insertions(+), 58 deletions(-) delete mode 100644 website_search_products/data/ir_rule.xml diff --git a/website_search_products/controllers/controller.py b/website_search_products/controllers/controller.py index 463cb5e..b734bad 100644 --- a/website_search_products/controllers/controller.py +++ b/website_search_products/controllers/controller.py @@ -1,34 +1,47 @@ - # -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- from odoo import http from odoo.http import request from odoo.addons.website.controllers.main import Website import logging + _logger = logging.getLogger(__name__) + class IntentoryForm(http.Controller): - @http.route(['/inventory/search'], type='http', auth="user", website=True) + @http.route(["/inventory/search"], type="http", auth="user", website=True) def inventory_form(self, **post): - if not request.env['res.users'].browse(request.uid).has_group('base.group_portal')\ - and not request.env['res.users'].browse(request.uid).has_group('base.group_user'): - redirect = b'/web?' + if not request.env["res.users"].browse(request.uid).has_group( + "base.group_portal" + ) and not request.env["res.users"].browse(request.uid).has_group( + "base.group_user" + ): + redirect = b"/web?" return http.redirect_with_hash(redirect) - products = request.env["product.template"].search([('active', '=', 'True'), ('available_in_pos', '=', 'True')]) - vals = {'products': products} + products = ( + request.env["product.template"] + .sudo() + .search([("active", "=", "True"), ("available_in_pos", "=", "True")]) + ) + vals = {"products": products} return request.render("website_search_products.web_list_products", vals) - + class Website(Website): @http.route(website=True, auth="public") def web_login(self, redirect=None, *args, **kw): response = super(Website, self).web_login(redirect=redirect, *args, **kw) - if not redirect and request.params['login_success']: - if request.env['res.users'].browse(request.uid).has_group('base.group_user'): - redirect = b'/web?' + request.httprequest.query_string + if not redirect and request.params["login_success"]: + if ( + request.env["res.users"] + .browse(request.uid) + .has_group("base.group_user") + ): + redirect = b"/web?" + request.httprequest.query_string else: - redirect = '/inventory/search' + redirect = "/inventory/search" return http.redirect_with_hash(redirect) return response diff --git a/website_search_products/data/ir_rule.xml b/website_search_products/data/ir_rule.xml deleted file mode 100644 index 1c1ab21..0000000 --- a/website_search_products/data/ir_rule.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - Portal Consult Products - - - - - - - - - \ No newline at end of file diff --git a/website_search_products/views/web_templates.xml b/website_search_products/views/web_templates.xml index 47c03be..dab3f6a 100644 --- a/website_search_products/views/web_templates.xml +++ b/website_search_products/views/web_templates.xml @@ -9,57 +9,70 @@
-
- Displayed products -
+
+ Displayed products +
-
- Products not found -
+
+ Products not found +
-

In this table you can consult all the products available in the store

+
+

In this table you can consult all the products available in the + store

+
- +
- + - + - - - - - + + + + + - +
NameCategoryCategory Price Quantity UoM
+ + + + + + + + + +
- - - + + + + + - - - + \ No newline at end of file From e6d6ad01ef881cef928b1e762143c9adcd766643 Mon Sep 17 00:00:00 2001 From: luis Date: Tue, 20 Feb 2024 10:50:37 +0100 Subject: [PATCH 2/2] website_search_products: Fix manifest --- website_search_products/__manifest__.py | 26 +++++++++---------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/website_search_products/__manifest__.py b/website_search_products/__manifest__.py index 9f95ae0..44e654c 100644 --- a/website_search_products/__manifest__.py +++ b/website_search_products/__manifest__.py @@ -2,22 +2,14 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Website Search Products', - 'description': """ + "name": "Website Search Products", + "description": """ Allows portal users to search products in a table with filters.""", - 'version': '12.0.1.0.0', - 'license': 'AGPL-3', - 'author': 'Criptomart', - 'website': 'https://criptomart.net', - 'depends': [ - "stock", - "website" - ], - 'data': [ - "data/menu.xml", - "data/ir_rule.xml", - "views/web_templates.xml" - ], - 'demo': [ - ], + "version": "12.0.1.0.0", + "license": "AGPL-3", + "author": "Criptomart", + "website": "https://criptomart.net", + "depends": ["stock", "website"], + "data": ["data/menu.xml", "views/web_templates.xml"], + "demo": [], }