Compare commits

..

No commits in common. "7a0cf23df9948b1c5a7b9b2dc27e10050df30d94" and "f3aa16180750e8b858663fc74ea295a7f4a2d048" have entirely different histories.

12 changed files with 33 additions and 222 deletions

37
.gitignore vendored
View File

@ -1,37 +0,0 @@
# Python
__pycache__/
*.py[cod]
*$py.class
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# Odoo
*.log
.pylintrc
.pylint.d/
# VS Code
.vscode/
# PyCharm
.idea/
# Translations
*.pot
*.po

View File

@ -10,7 +10,6 @@ Restrict visibility of the following records based on User configuration:
* **Locations** (`stock.location`)
* **Work Centers** (`mrp.workcenter`)
* **Approval Categories** (`approval.category`)
* **Quality Checks Button** (on Manufacturing Orders and Inventory Transfers)
## Configuration
@ -30,16 +29,6 @@ Restrict visibility of the following records based on User configuration:
* **Populated List = Restricted**: If one or more records are added, the user will **ONLY** see those specific records.
* **Superuser**: The Superuser (OdooBot) and administrators bypassing access rights are not affected by these restrictions.
## Quality Checks Button Restriction
The visibility of the "Quality Checks" and "Quality Alert" buttons on **Manufacturing Orders** and **Inventory Transfers** is controlled by a specific user setting.
To allow a user to see these buttons:
1. Navigate to **Settings > Users & Companies > Users**.
2. Enable the checkbox **"Is Allowed todo Quality Checks?"** in the **Access Restrictions** tab.
By default, this setting is unchecked, meaning users will **NOT** see these buttons unless explicitly allowed.
## Technical Details
This module overrides the `_search` method on the target models to apply a domain filter based on the current user's allowed list. This ensures consistency across views (list, kanban, many2one dropdowns) and avoids common issues associated with Record Rules.

View File

@ -16,12 +16,13 @@
""",
'category': 'Extra Tools',
'author': 'Suherdy Yacob',
'depends': ['base', 'stock', 'mrp', 'approvals', 'stock_account', 'sale', 'quality_mrp'],
'depends': ['base', 'stock', 'mrp', 'approvals', 'stock_account', 'sale', 'quality_control', 'quality_mrp'],
'data': [
'security/ir.model.access.csv',
'security/ir_rule.xml',
'security/ir_actions_act_window.xml',
'views/res_users_views.xml',
'views/stock_picking_views.xml',
'views/mrp_production_views.xml',
],
'installable': True,

View File

@ -1,10 +1,6 @@
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

View File

@ -3,7 +3,6 @@ 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')
@ -23,71 +22,3 @@ class MrpProduction(models.Model):
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.)

View File

@ -47,10 +47,3 @@ class ResUsers(models.Model):
string="Allowed Approvals",
help="Approval Categories this user is allowed to access. Leave empty to restrict access to none."
)
allowed_quality_checks = fields.Boolean(
string="Is Allowed todo Quality Checks?",
default=False,
help="If checked, this user can see the Quality Checks button on Manufacturing Orders.",
prefetch=False,
)

View File

@ -3,7 +3,6 @@ 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')
@ -33,12 +32,3 @@ class StockPicking(models.Model):
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.)

View File

@ -1,60 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<<<<<<< HEAD:views/mrp_production_views.xml
<<<<<<< HEAD
<!-- Inherit from quality_mrp view -->
<record id="view_mrp_production_form_inherit_access_restriction" model="ir.ui.view">
=======
<record id="mrp_production_view_form_inherit_access_restriction" model="ir.ui.view">
>>>>>>> 3a96e90 (feat: Hide quality check buttons on manufacturing orders for specific user groups with exceptions for quality roles.)
=======
<record id="mrp_production_view_form_inherit_access_restriction_v19" model="ir.ui.view">
>>>>>>> 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
<field name="name">mrp.production.view.form.inherit.access.restriction</field>
<field name="model">mrp.production</field>
<field name="priority">99999</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<<<<<<< HEAD:views/mrp_production_views.xml
<<<<<<< HEAD
<<<<<<< HEAD
<field name="state" position="before">
<field name="restrict_quality_check_button" invisible="1"/>
</field>
<!-- Header Button -->
<xpath expr="//button[@name='check_quality']" position="attributes">
<attribute name="invisible">not quality_check_todo or restrict_quality_check_button</attribute>
</xpath>
<!-- Smart Buttons -->
<xpath expr="//button[@name='%(quality_mrp.quality_check_action_mo)d'][1]" position="attributes">
<attribute name="invisible">not check_ids or quality_check_fail or not quality_check_todo or restrict_quality_check_button</attribute>
</xpath>
<xpath expr="//button[@name='%(quality_mrp.quality_check_action_mo)d'][2]" position="attributes">
<attribute name="invisible">not check_ids or quality_check_fail or quality_check_todo or restrict_quality_check_button</attribute>
</xpath>
<xpath expr="//button[@name='%(quality_mrp.quality_check_action_mo)d'][3]" position="attributes">
<attribute name="invisible">not check_ids or not quality_check_fail or restrict_quality_check_button</attribute>
</xpath>
=======
<xpath expr="//header" position="inside">
=======
<xpath expr="//sheet" position="inside">
>>>>>>> 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.)
=======
<sheet position="inside">
>>>>>>> 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
<field name="hide_quality_check_button" invisible="1"/>
</sheet>
<xpath expr="//button[@name='check_quality']" position="attributes">
<attribute name="invisible">hide_quality_check_button</attribute>
</xpath>
<xpath expr="//button[@name='button_quality_alert']" position="attributes">
<attribute name="invisible">hide_quality_check_button</attribute>
</xpath>
>>>>>>> 3a96e90 (feat: Hide quality check buttons on manufacturing orders for specific user groups with exceptions for quality roles.)
</field>
</record>
</odoo>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Inherit from quality_mrp view -->
<record id="view_mrp_production_form_inherit_access_restriction" model="ir.ui.view">
<field name="name">mrp.production.view.form.inherit.access.restriction</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="quality_mrp.mrp_production_view_form_inherit_quality"/>
<field name="arch" type="xml">
<field name="state" position="before">
<field name="restrict_quality_check_button" invisible="1"/>
</field>
<!-- Header Button -->
<xpath expr="//button[@name='check_quality']" position="attributes">
<attribute name="invisible">not quality_check_todo or restrict_quality_check_button</attribute>
</xpath>
<!-- Smart Buttons -->
<xpath expr="//button[@name='%(quality_mrp.quality_check_action_mo)d'][1]" position="attributes">
<attribute name="invisible">not check_ids or quality_check_fail or not quality_check_todo or restrict_quality_check_button</attribute>
</xpath>
<xpath expr="//button[@name='%(quality_mrp.quality_check_action_mo)d'][2]" position="attributes">
<attribute name="invisible">not check_ids or quality_check_fail or quality_check_todo or restrict_quality_check_button</attribute>
</xpath>
<xpath expr="//button[@name='%(quality_mrp.quality_check_action_mo)d'][3]" position="attributes">
<attribute name="invisible">not check_ids or not quality_check_fail or restrict_quality_check_button</attribute>
</xpath>
</field>
</record>
</odoo>

View File

@ -16,7 +16,6 @@
<group string="Manufacturing &amp; others">
<field name="allowed_workcenter_ids" widget="many2many_tags"/>
<field name="allowed_approval_category_ids" widget="many2many_tags"/>
<field name="allowed_quality_checks"/>
</group>
</group>
</page>

View File

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<<<<<<< HEAD:views/stock_picking_views.xml
<<<<<<< HEAD
<!-- Inherit from the quality control view that adds the button -->
<!-- We need to ensure we target the right buttons. The Quality Checks button is added by quality_control/views/stock_picking_views.xml -->
<!-- The button names are 'check_quality', 'open_quality_alert_picking', 'action_open_quality_check_picking' -->
@ -34,26 +32,6 @@
<attribute name="invisible">not check_ids or not quality_check_fail or restrict_quality_check_button</attribute>
</xpath>
=======
<record id="stock_picking_view_form_inherit_access_restriction" model="ir.ui.view">
=======
<record id="stock_picking_view_form_inherit_access_restriction_v19" model="ir.ui.view">
>>>>>>> 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
<field name="name">stock.picking.view.form.inherit.access.restriction</field>
<field name="model">stock.picking</field>
<field name="priority">1000</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="inside">
<field name="hide_quality_check_button" invisible="1"/>
</xpath>
<xpath expr="//button[@name='check_quality']" position="attributes">
<attribute name="invisible">hide_quality_check_button</attribute>
</xpath>
<xpath expr="//button[@name='button_quality_alert']" position="attributes">
<attribute name="invisible">hide_quality_check_button</attribute>
</xpath>
>>>>>>> 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.)
</field>
</record>
</odoo>