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.
This commit is contained in:
parent
88494104cc
commit
4eee218534
13
README.md
13
README.md
@ -10,7 +10,7 @@ Restrict visibility of the following records based on User configuration:
|
|||||||
* **Locations** (`stock.location`)
|
* **Locations** (`stock.location`)
|
||||||
* **Work Centers** (`mrp.workcenter`)
|
* **Work Centers** (`mrp.workcenter`)
|
||||||
* **Approval Categories** (`approval.category`)
|
* **Approval Categories** (`approval.category`)
|
||||||
* **Quality Checks Button** (on Manufacturing Orders)
|
* **Quality Checks Button** (on Manufacturing Orders and Inventory Transfers)
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
@ -32,12 +32,13 @@ Restrict visibility of the following records based on User configuration:
|
|||||||
|
|
||||||
## Quality Checks Button Restriction
|
## Quality Checks Button Restriction
|
||||||
|
|
||||||
The "Quality Checks" button on Manufacturing Orders is automatically hidden for users who belong to the following groups:
|
The visibility of the "Quality Checks" and "Quality Alert" buttons on **Manufacturing Orders** and **Inventory Transfers** is controlled by a specific user setting.
|
||||||
* **Inventory User**
|
|
||||||
* **Manufacturing User**
|
|
||||||
* **MPS User**
|
|
||||||
|
|
||||||
**Exception**: If a user in these groups is *also* assigned the **Quality User** or **Quality Manager** role, the button will remain visible.
|
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
|
## Technical Details
|
||||||
|
|
||||||
|
|||||||
@ -16,12 +16,13 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'Extra Tools',
|
'category': 'Extra Tools',
|
||||||
'author': 'Suherdy Yacob',
|
'author': 'Suherdy Yacob',
|
||||||
'depends': ['base', 'stock', 'mrp', 'approvals', 'stock_account', 'sale'],
|
'depends': ['base', 'stock', 'mrp', 'approvals', 'stock_account', 'sale', 'quality_mrp'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'security/ir_rule.xml',
|
'security/ir_rule.xml',
|
||||||
'security/ir_actions_act_window.xml',
|
'security/ir_actions_act_window.xml',
|
||||||
'views/res_users_views.xml',
|
'views/res_users_views.xml',
|
||||||
|
'views/mrp_production_views.xml',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'application': False,
|
'application': False,
|
||||||
|
|||||||
@ -6,4 +6,5 @@ from . import stock_picking
|
|||||||
=======
|
=======
|
||||||
>>>>>>> 3a96e90 (feat: Hide quality check buttons on manufacturing orders for specific user groups with exceptions for quality roles.)
|
>>>>>>> 3a96e90 (feat: Hide quality check buttons on manufacturing orders for specific user groups with exceptions for quality roles.)
|
||||||
from . import mrp_production
|
from . import mrp_production
|
||||||
|
from . import stock_picking
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@ -26,9 +26,11 @@ class MrpProduction(models.Model):
|
|||||||
=======
|
=======
|
||||||
hide_quality_check_button = fields.Boolean(compute='_compute_hide_quality_check_button')
|
hide_quality_check_button = fields.Boolean(compute='_compute_hide_quality_check_button')
|
||||||
|
|
||||||
|
@api.depends('product_id')
|
||||||
@api.depends_context('uid')
|
@api.depends_context('uid')
|
||||||
def _compute_hide_quality_check_button(self):
|
def _compute_hide_quality_check_button(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
|
<<<<<<< HEAD
|
||||||
user = self.env.user
|
user = self.env.user
|
||||||
|
|
||||||
# Define the restricted groups
|
# Define the restricted groups
|
||||||
@ -83,3 +85,9 @@ class MrpProduction(models.Model):
|
|||||||
else:
|
else:
|
||||||
record.hide_quality_check_button = False
|
record.hide_quality_check_button = False
|
||||||
>>>>>>> 3a96e90 (feat: Hide quality check buttons on manufacturing orders for specific user groups with exceptions for quality roles.)
|
>>>>>>> 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.)
|
||||||
|
|||||||
@ -47,3 +47,9 @@ class ResUsers(models.Model):
|
|||||||
string="Allowed Approvals",
|
string="Allowed Approvals",
|
||||||
help="Approval Categories this user is allowed to access. Leave empty to restrict access to none."
|
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."
|
||||||
|
)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ from odoo import models, fields, api
|
|||||||
class StockPicking(models.Model):
|
class StockPicking(models.Model):
|
||||||
_inherit = 'stock.picking'
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
restrict_quality_check_button = fields.Boolean(compute='_compute_restrict_quality_check_button')
|
restrict_quality_check_button = fields.Boolean(compute='_compute_restrict_quality_check_button')
|
||||||
|
|
||||||
@api.depends_context('uid')
|
@api.depends_context('uid')
|
||||||
@ -32,3 +33,12 @@ class StockPicking(models.Model):
|
|||||||
picking.restrict_quality_check_button = True
|
picking.restrict_quality_check_button = True
|
||||||
else:
|
else:
|
||||||
picking.restrict_quality_check_button = False
|
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.)
|
||||||
|
|||||||
@ -8,8 +8,10 @@
|
|||||||
>>>>>>> 3a96e90 (feat: Hide quality check buttons on manufacturing orders for specific user groups with exceptions for quality roles.)
|
>>>>>>> 3a96e90 (feat: Hide quality check buttons on manufacturing orders for specific user groups with exceptions for quality roles.)
|
||||||
<field name="name">mrp.production.view.form.inherit.access.restriction</field>
|
<field name="name">mrp.production.view.form.inherit.access.restriction</field>
|
||||||
<field name="model">mrp.production</field>
|
<field name="model">mrp.production</field>
|
||||||
<field name="inherit_id" ref="quality_mrp.mrp_production_view_form_inherit_quality"/>
|
<field name="priority">99999</field>
|
||||||
|
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
<field name="state" position="before">
|
<field name="state" position="before">
|
||||||
<field name="restrict_quality_check_button" invisible="1"/>
|
<field name="restrict_quality_check_button" invisible="1"/>
|
||||||
@ -33,6 +35,9 @@
|
|||||||
|
|
||||||
=======
|
=======
|
||||||
<xpath expr="//header" position="inside">
|
<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.)
|
||||||
<field name="hide_quality_check_button" invisible="1"/>
|
<field name="hide_quality_check_button" invisible="1"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//button[@name='check_quality']" position="attributes">
|
<xpath expr="//button[@name='check_quality']" position="attributes">
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
<group string="Manufacturing & others">
|
<group string="Manufacturing & others">
|
||||||
<field name="allowed_workcenter_ids" widget="many2many_tags"/>
|
<field name="allowed_workcenter_ids" widget="many2many_tags"/>
|
||||||
<field name="allowed_approval_category_ids" widget="many2many_tags"/>
|
<field name="allowed_approval_category_ids" widget="many2many_tags"/>
|
||||||
|
<field name="allowed_quality_checks"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
<<<<<<< HEAD
|
||||||
<!-- Inherit from the quality control view that adds the button -->
|
<!-- 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 -->
|
<!-- 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' -->
|
<!-- The button names are 'check_quality', 'open_quality_alert_picking', 'action_open_quality_check_picking' -->
|
||||||
@ -32,6 +33,23 @@
|
|||||||
<attribute name="invisible">not check_ids or not quality_check_fail or restrict_quality_check_button</attribute>
|
<attribute name="invisible">not check_ids or not quality_check_fail or restrict_quality_check_button</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
|
=======
|
||||||
|
<record id="stock_picking_view_form_inherit_access_restriction" model="ir.ui.view">
|
||||||
|
<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>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user