diff --git a/__manifest__.py b/__manifest__.py index cc224c6..20bf56c 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'Access Restriction By User', - 'version': '19.0.1.0.0', + 'version': '19.0.1.0.1', 'summary': 'Restrict access to Warehouses, Picking Types, Locations, Work Centers, and Approvals by User', 'description': """ Restricts visibility of: @@ -22,7 +22,8 @@ 'security/ir_rule.xml', 'security/ir_actions_act_window.xml', 'views/res_users_views.xml', - 'views/mrp_production_views.xml', + 'views/mrp_production_v19.xml', + 'views/stock_picking_v19.xml', ], 'installable': True, 'application': False, diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 06b8be2..0000000 Binary files a/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/models/__init__.py b/models/__init__.py index 867dcf2..cd621b7 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,10 +1,5 @@ from . import res_users from . import restricted_models from . import sale_order -<<<<<<< HEAD -from . import stock_picking -======= ->>>>>>> 3a96e90 (feat: Hide quality check buttons on manufacturing orders for specific user groups with exceptions for quality roles.) from . import mrp_production from . import stock_picking - diff --git a/models/__pycache__/__init__.cpython-312.pyc b/models/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 1fcec0c..0000000 Binary files a/models/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/models/__pycache__/mrp_production.cpython-312.pyc b/models/__pycache__/mrp_production.cpython-312.pyc deleted file mode 100644 index 79c6dea..0000000 Binary files a/models/__pycache__/mrp_production.cpython-312.pyc and /dev/null differ diff --git a/models/__pycache__/res_users.cpython-312.pyc b/models/__pycache__/res_users.cpython-312.pyc deleted file mode 100644 index 320b9bb..0000000 Binary files a/models/__pycache__/res_users.cpython-312.pyc and /dev/null differ diff --git a/models/__pycache__/restricted_models.cpython-312.pyc b/models/__pycache__/restricted_models.cpython-312.pyc deleted file mode 100644 index 2c06866..0000000 Binary files a/models/__pycache__/restricted_models.cpython-312.pyc and /dev/null differ diff --git a/models/__pycache__/sale_order.cpython-312.pyc b/models/__pycache__/sale_order.cpython-312.pyc deleted file mode 100644 index 4517426..0000000 Binary files a/models/__pycache__/sale_order.cpython-312.pyc and /dev/null differ diff --git a/models/__pycache__/stock_picking.cpython-312.pyc b/models/__pycache__/stock_picking.cpython-312.pyc deleted file mode 100644 index 4e9434b..0000000 Binary files a/models/__pycache__/stock_picking.cpython-312.pyc and /dev/null differ diff --git a/models/mrp_production.py b/models/mrp_production.py index 97a2e08..d66557b 100644 --- a/models/mrp_production.py +++ b/models/mrp_production.py @@ -3,91 +3,9 @@ from odoo import models, fields, api class MrpProduction(models.Model): _inherit = 'mrp.production' -<<<<<<< HEAD - restrict_quality_check_button = fields.Boolean(compute='_compute_restrict_quality_check_button') - - @api.depends_context('uid') - def _compute_restrict_quality_check_button(self): - user = self.env.user - for production in self: - is_inventory_user = user.has_group('stock.group_stock_user') - is_mrp_user = user.has_group('mrp.group_mrp_user') - is_mrp_manager = user.has_group('mrp.group_mrp_manager') - - is_restricted_role = is_inventory_user or is_mrp_user or is_mrp_manager - - is_quality_manager = user.has_group('quality.group_quality_manager') - is_system = user.has_group('base.group_system') - - if is_restricted_role and not (is_quality_manager or is_system): - production.restrict_quality_check_button = True - else: - production.restrict_quality_check_button = False -======= hide_quality_check_button = fields.Boolean(compute='_compute_hide_quality_check_button') - @api.depends('product_id') @api.depends_context('uid') def _compute_hide_quality_check_button(self): for record in self: -<<<<<<< HEAD - user = self.env.user - - # Define the restricted groups - # 1. Inventory User (stock.group_stock_user) - # 2. Manufacturing User (mrp.group_mrp_user) - # 3. MPS User (mrp_mps.group_mrp_mps) - handled safely - - is_restricted = False - - if user.has_group('stock.group_stock_user') or user.has_group('mrp.group_mrp_user'): - is_restricted = True - - # Check MPS User group safely as it might not be installed or ID might differ - if not is_restricted: - if user.has_group('mrp_mps.group_mrp_mps'): - is_restricted = True - else: - # Fallback search by name if XML ID not found or module not standard in this env - if self.env['res.groups'].search_count([('name', '=', 'MPS User'), ('id', 'in', user.groups_id.ids)]): - is_restricted = True - - # Logic: If user is in ANY of the restricted groups, we hide the button. - # However, usually "Manager" groups inherit "User" groups. - # So a Manager would also be a User. - # We must Ensure that we DO NOT hide it if the user is a Quality Manager or Quality User? - # The request says: "only hide ... from user in inventory user group, manufacturing user group and MPS user group" - # It implies if I am ONLY one of those, I shouldn't see it. - # But if I am ALSO a Quality User, should I see it? - # Usually, Quality User > Inventory User regarding Quality checks. - # If I hide it for Inventory User, and I am both Inventory User AND Quality User, I will simply NOT see it if I check "if has_group(Inventory)". - # So I should probably check if the user is NOT a Quality User/Manager. - - # But the user request is specific: "change the logic... to only hide ... from user in [groups]" - # If I am an Inventory User, I shouldn't see it. - # If I am also a Quality User, do I see it? Standard Odoo: Quality Users see it. - # If the user wants to restriction, likely they want these specific functional users NOT to do quality checks - # UNLESS they are explicitly Quality Users? - # Or maybe they want to hide it EVEN IF they are Quality Users? - # "Only hide ... from user in ..." suggests targeting these specific roles. - - # Let's refine the logic: - # Hide IF (User is Inventory OR Mfg OR MPS) AND (User is NOT Quality Manager/User?) - # Or is it a hard hide? "Only hide ... from [list]" - # If I assume the user implies "People who are just Inventory/Mfg/MPS users shouldn't see this", - # then if someone is ALSO a Quality Manager, they should probably see it. - # So I will add an exception: If user is Quality User+, they see it. - - is_quality_user = user.has_group('quality.group_quality_user') or user.has_group('quality.group_quality_manager') - - if is_restricted and not is_quality_user: - record.hide_quality_check_button = True - else: - record.hide_quality_check_button = False ->>>>>>> 3a96e90 (feat: Hide quality check buttons on manufacturing orders for specific user groups with exceptions for quality roles.) -======= - # Logic: Hide logic is inverse of "is allowed" - # If allowed_quality_checks is True, hide = False - # If allowed_quality_checks is False, hide = True record.hide_quality_check_button = not self.env.user.allowed_quality_checks ->>>>>>> 4a049d1 (feat: Implement user-specific control for quality check button visibility on manufacturing orders and inventory transfers via a new `allowed_quality_checks` field on users.) diff --git a/models/stock_picking.py b/models/stock_picking.py index 7538df2..15c729f 100644 --- a/models/stock_picking.py +++ b/models/stock_picking.py @@ -3,42 +3,9 @@ from odoo import models, fields, api class StockPicking(models.Model): _inherit = 'stock.picking' -<<<<<<< HEAD - restrict_quality_check_button = fields.Boolean(compute='_compute_restrict_quality_check_button') - - @api.depends_context('uid') - def _compute_restrict_quality_check_button(self): - user = self.env.user - for picking in self: - # Check if user is in restricted groups (Inventory User or MPS User/Manager) - # MPS user usually relates to Manufacturing Manager or User, but user specifically asked for "MPS User". - # Since there is no widespread "MPS User" group in standard, we assume it falls under Manufacturing. - # However, we will check strictly for the groups mentioned in the request: - # Inventory User: stock.group_stock_user - # Manufacturing User: mrp.group_mrp_user - # MPS User: mrp.group_mrp_manager (often implies MPS access) - - is_inventory_user = user.has_group('stock.group_stock_user') - is_mrp_user = user.has_group('mrp.group_mrp_user') - is_mrp_manager = user.has_group('mrp.group_mrp_manager') - - # User is possibly restricted if they have one of these basic roles - is_restricted_role = is_inventory_user or is_mrp_user or is_mrp_manager - - # But we must NOT hide if they are Quality Manager or System Admin - is_quality_manager = user.has_group('quality.group_quality_manager') - is_system = user.has_group('base.group_system') - - if is_restricted_role and not (is_quality_manager or is_system): - picking.restrict_quality_check_button = True - else: - picking.restrict_quality_check_button = False -======= hide_quality_check_button = fields.Boolean(compute='_compute_hide_quality_check_button') - @api.depends('picking_type_id') @api.depends_context('uid') def _compute_hide_quality_check_button(self): for record in self: record.hide_quality_check_button = not self.env.user.allowed_quality_checks ->>>>>>> 4a049d1 (feat: Implement user-specific control for quality check button visibility on manufacturing orders and inventory transfers via a new `allowed_quality_checks` field on users.) diff --git a/views/mrp_production_v19.xml b/views/mrp_production_v19.xml index bf9a355..d351961 100644 --- a/views/mrp_production_v19.xml +++ b/views/mrp_production_v19.xml @@ -1,51 +1,12 @@ -<<<<<<< HEAD:views/mrp_production_views.xml -<<<<<<< HEAD - - -======= - ->>>>>>> 3a96e90 (feat: Hide quality check buttons on manufacturing orders for specific user groups with exceptions for quality roles.) -======= ->>>>>>> 5091c7f (feat: Update module to Odoo 19 by bumping version, adapting MRP and Stock Picking views, and removing stock valuation layer access rules.):views/mrp_production_v19.xml mrp.production.view.form.inherit.access.restriction mrp.production 99999 -<<<<<<< HEAD:views/mrp_production_views.xml -<<<<<<< HEAD -<<<<<<< HEAD - - - - - - - not quality_check_todo or restrict_quality_check_button - - - - - not check_ids or quality_check_fail or not quality_check_todo or restrict_quality_check_button - - - not check_ids or quality_check_fail or quality_check_todo or restrict_quality_check_button - - - not check_ids or not quality_check_fail or restrict_quality_check_button - - -======= - -======= - ->>>>>>> 4a049d1 (feat: Implement user-specific control for quality check button visibility on manufacturing orders and inventory transfers via a new `allowed_quality_checks` field on users.) -======= ->>>>>>> 5091c7f (feat: Update module to Odoo 19 by bumping version, adapting MRP and Stock Picking views, and removing stock valuation layer access rules.):views/mrp_production_v19.xml @@ -54,7 +15,6 @@ hide_quality_check_button ->>>>>>> 3a96e90 (feat: Hide quality check buttons on manufacturing orders for specific user groups with exceptions for quality roles.) diff --git a/views/stock_picking_v19.xml b/views/stock_picking_v19.xml index fd62f27..d4e1664 100644 --- a/views/stock_picking_v19.xml +++ b/views/stock_picking_v19.xml @@ -1,44 +1,6 @@ -<<<<<<< HEAD:views/stock_picking_views.xml -<<<<<<< HEAD - - - - - - stock.picking.view.form.inherit.access.restriction - stock.picking - - - - - - - - - not quality_check_todo or state in ('done', 'cancel') or restrict_quality_check_button - - - - - - - - not check_ids or quality_check_fail or not quality_check_todo or restrict_quality_check_button - - - not check_ids or quality_check_fail or quality_check_todo or restrict_quality_check_button - - - not check_ids or not quality_check_fail or restrict_quality_check_button - - -======= - -======= ->>>>>>> 5091c7f (feat: Update module to Odoo 19 by bumping version, adapting MRP and Stock Picking views, and removing stock valuation layer access rules.):views/stock_picking_v19.xml stock.picking.view.form.inherit.access.restriction stock.picking 1000 @@ -53,7 +15,6 @@ hide_quality_check_button ->>>>>>> 4a049d1 (feat: Implement user-specific control for quality check button visibility on manufacturing orders and inventory transfers via a new `allowed_quality_checks` field on users.)