diff --git a/product_restriction_users/README.rst b/product_restriction_users/README.rst index bfeb889fd..4087f435e 100644 --- a/product_restriction_users/README.rst +++ b/product_restriction_users/README.rst @@ -1,18 +1,16 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 -Product Restriction On Users -============================ - +Product Restriction Users +========================= This module used to allow products to user or only access products -related to allowed categories or Allow access of products/category to user - -Installation -============ -- www.odoo.com/documentation/15.0/setup/install.html -- Install our custom addon +related to allowed categories or Allow access of products/category to user. +Configuration +============= +* Need to set a Restriction Type to choose the allowed products and product + categories in Users. Company ------- @@ -20,9 +18,7 @@ Company Credits ------- -* Developer: -(V16) Mruthul @ Cybrosys - +* Developer: (V16) Mruthul Raj, Contacts:odoo@cybrosys.com Contacts -------- @@ -30,7 +26,8 @@ Contacts Bug Tracker ----------- -Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. +Bugs are tracked on GitHub Issues. In case of trouble, please check there if +your issue has already been reported. Maintainer ========== diff --git a/product_restriction_users/__init__.py b/product_restriction_users/__init__.py index c0236ffbb..9c6d516ed 100644 --- a/product_restriction_users/__init__.py +++ b/product_restriction_users/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -################################################################################ +############################################################################### # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2023-TODAY Cybrosys Technologies(). -# Author: Mruthul (odoo@cybrosys.com) +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Mruthul Raj(odoo@cybrosys.com) # # You can modify it under the terms of the GNU AFFERO # GENERAL PUBLIC LICENSE (AGPL v3), Version 3. @@ -18,5 +18,5 @@ # (AGPL v3) along with this program. # If not, see . # -################################################################################ +############################################################################### from . import models diff --git a/product_restriction_users/__manifest__.py b/product_restriction_users/__manifest__.py index 3aa31a328..d8d31bc9b 100644 --- a/product_restriction_users/__manifest__.py +++ b/product_restriction_users/__manifest__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -################################################################################ +############################################################################### # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2023-TODAY Cybrosys Technologies(). -# Author: Mruthul (odoo@cybrosys.com) +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Mruthul Raj(odoo@cybrosys.com) # # You can modify it under the terms of the GNU AFFERO # GENERAL PUBLIC LICENSE (AGPL v3), Version 3. @@ -18,14 +18,12 @@ # (AGPL v3) along with this program. # If not, see . # -################################################################################ +############################################################################### { - 'name': "Product Restriction On Users", - 'version': '16.0.1.0.0', + 'name': "Product Restriction Users", + 'version': '16.0.1.0.1', 'category': "Inventory", - 'summary': """The module product_restriction_users is used to allow users - to access products or related products only with authorization, - or to allow users to access products/categories.""", + 'summary': "Restrict products for users based on products and categories.", 'description': """This module used to allow products to user or only access products related to allowed categories or Allow access of products/category to user""", @@ -33,7 +31,7 @@ 'company': 'Cybrosys Techno Solutions', 'website': "https://www.cybrosys.com", 'maintainer': 'Cybrosys Techno Solutions', - 'depends': ['base', 'stock'], + 'depends': ['stock'], 'data': [ 'security/product_template_security.xml', 'views/res_users_views.xml', diff --git a/product_restriction_users/doc/RELEASE_NOTES.md b/product_restriction_users/doc/RELEASE_NOTES.md index 12e22d472..7534739a7 100644 --- a/product_restriction_users/doc/RELEASE_NOTES.md +++ b/product_restriction_users/doc/RELEASE_NOTES.md @@ -4,3 +4,8 @@ #### Version 16.0.1.0.0 #### ADD - Initial commit for Product Restriction Users + +#### 16.10.2023 +#### Version 16.0.1.0.1 +#### ADD +- Bug Fix - Fixed the issue in allowed product categories. diff --git a/product_restriction_users/models/__init__.py b/product_restriction_users/models/__init__.py index 3d786d371..4518eccb0 100644 --- a/product_restriction_users/models/__init__.py +++ b/product_restriction_users/models/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -################################################################################ +############################################################################### # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2023-TODAY Cybrosys Technologies(). -# Author: Mruthul (odoo@cybrosys.com) +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Mruthul Raj(odoo@cybrosys.com) # # You can modify it under the terms of the GNU AFFERO # GENERAL PUBLIC LICENSE (AGPL v3), Version 3. @@ -18,6 +18,6 @@ # (AGPL v3) along with this program. # If not, see . # -################################################################################ +############################################################################### from . import product_template from . import res_users diff --git a/product_restriction_users/models/product_template.py b/product_restriction_users/models/product_template.py index dbac335b9..cdc9d6b40 100644 --- a/product_restriction_users/models/product_template.py +++ b/product_restriction_users/models/product_template.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -################################################################################ +############################################################################### # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2023-TODAY Cybrosys Technologies(). -# Author: Mruthul (odoo@cybrosys.com) +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Mruthul Raj(odoo@cybrosys.com) # # You can modify it under the terms of the GNU AFFERO # GENERAL PUBLIC LICENSE (AGPL v3), Version 3. @@ -18,7 +18,7 @@ # (AGPL v3) along with this program. # If not, see . # -################################################################################ +############################################################################### from odoo import fields, models diff --git a/product_restriction_users/models/res_users.py b/product_restriction_users/models/res_users.py index 907af43b9..91fa9e68f 100644 --- a/product_restriction_users/models/res_users.py +++ b/product_restriction_users/models/res_users.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -################################################################################ +############################################################################### # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2023-TODAY Cybrosys Technologies(). -# Author: Mruthul (odoo@cybrosys.com) +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Mruthul Raj(odoo@cybrosys.com) # # You can modify it under the terms of the GNU AFFERO # GENERAL PUBLIC LICENSE (AGPL v3), Version 3. @@ -18,23 +18,25 @@ # (AGPL v3) along with this program. # If not, see . # -################################################################################ -from odoo import fields, models +############################################################################### +from odoo import fields, models, Command class ResUsers(models.Model): - """ Inherited the res.users model for adding the products + """ Inherited the res_users model for adding the products and product category""" _inherit = 'res.users' - restricted_type = fields.Selection([('product', 'Product'), ( - 'category', 'Category')], string='Restriction Type', default='product', + restricted_type = fields.Selection([('product', 'Product'), + ('category', 'Category')], + string='Restriction Type', + default='product', help='choose Product and Product ' 'category depends upon your need') allowed_product_ids = fields.Many2many('product.template', string="Products", store=True, - help='Show to allow the products for' - ' assigned users') + help='Show to allow the products ' + 'for assigned users') allowed_product_category_ids = fields.Many2many('product.category', string="Product Category", store=True, @@ -67,22 +69,28 @@ class ResUsers(models.Model): 'restrict_user_ids': [(4, user.id)] }) else: + products = self.env['product.template'].sudo().search([]) if user.allowed_product_category_ids: - products = self.env['product.template'].sudo().search([]) - products.restrict_user_ids = False products.is_product = False products_categ = self.env['product.template']. \ search([('categ_id', 'in', [int(categ.id) for categ in user.allowed_product_category_ids]) ]) + for pro in products: + if pro not in products_categ: + pro.sudo().write({'restrict_user_ids': [Command.unlink(user.id)]}) + for product in products_categ: product.is_product = False product.sudo().write({ 'restrict_user_ids': [(4, user.id)] }) else: - products = self.env['product.template'].sudo().search([]) products.is_product = True + for product in products: + if user in product.restrict_user_ids: + product.sudo().write( + {'restrict_user_ids': [Command.unlink(user.id)]}) return res def _compute_is_admin(self): diff --git a/product_restriction_users/security/product_template_security.xml b/product_restriction_users/security/product_template_security.xml index bf135046c..babbfb25f 100644 --- a/product_restriction_users/security/product_template_security.xml +++ b/product_restriction_users/security/product_template_security.xml @@ -24,4 +24,4 @@ - \ No newline at end of file + diff --git a/product_restriction_users/static/description/index.html b/product_restriction_users/static/description/index.html index edd469993..b1cce46d8 100644 --- a/product_restriction_users/static/description/index.html +++ b/product_restriction_users/static/description/index.html @@ -2,7 +2,8 @@
- +
Community
- Odoo.sh + Enterprise
- Enterprise + Odoo.sh
@@ -27,8 +28,9 @@

- Product Restriction On Users

-

A Module For + Product Restriction Users +

+ A Module For Configuring the Product Restriction on Users.

@@ -42,12 +44,15 @@
-
+
-

Explore This +

+ Explore This Module

@@ -97,93 +102,117 @@ -
+
-

Overview +

+ Overview

-
+
This module used to allow products to user or only access products - related to allowed categories or Allow access of products/category to user. + related to allowed categories or Allow access of products/category to + user.
-
+
-

Features +

+ Features

-
+
-
+
- Configure the User Settings. + Admin can choose the products and categories that allowed for users.
-
+
- Configure to Allow only selected products to user. + Option to restrict both products and categories.
-
+
- Configure to Allow to show the products based on category Category to user. + Separate configuration for allowed products and categories in Users.
-
+
- Available in Odoo 16.0 both enterprise and - Community + Compatible with Community, Enterprise and Odoo.sh
-
+
-

Screenshots +

+ Screenshots

-

Configure User +

+ Configure User Settings

-

Set a restriction type - for to allow product and product category based on the selection of product and - category and added the allowed products in the user.

+

+ Set a Restriction Type to allow product and product + category. Based on this, add the allowed products in the + user.

-

Showing the allowed products on the user Marc Demo +

+ Showing the allowed products on the user Marc Demo.

-

Login as the user - Mitchel Admin and set restriction type as category +

+ Login as the user Mitchel Admin and set restriction + type as category.

-

Showing the allowed products based on choosen product category on the user Marc Demo +

+ Showing the allowed products based on chosen product category + on the user Marc Demo.

@@ -193,12 +222,15 @@ -
+
-

Related +

+ Related Products

@@ -208,52 +240,71 @@