Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b9b6e549c0 | |||
| 4a049d124e | |||
| 3a96e90596 |
37
.gitignore
vendored
Normal file
37
.gitignore
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# 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
|
||||||
11
README.md
11
README.md
@ -10,6 +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 and Inventory Transfers)
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
@ -29,6 +30,16 @@ 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.
|
* **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.
|
* **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
|
## 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.
|
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.
|
||||||
|
|||||||
@ -16,12 +16,14 @@
|
|||||||
""",
|
""",
|
||||||
'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', 'quality_control'],
|
||||||
'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',
|
||||||
|
'views/stock_picking_views.xml',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'application': False,
|
'application': False,
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
from . import res_users
|
from . import res_users
|
||||||
from . import restricted_models
|
from . import restricted_models
|
||||||
from . import sale_order
|
from . import sale_order
|
||||||
|
from . import mrp_production
|
||||||
|
from . import stock_picking
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21
models/mrp_production.py
Normal file
21
models/mrp_production.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
class MrpProduction(models.Model):
|
||||||
|
_inherit = 'mrp.production'
|
||||||
|
|
||||||
|
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:
|
||||||
|
# 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
|
||||||
|
|
||||||
|
def action_confirm(self):
|
||||||
|
return super(MrpProduction, self.with_context(bypass_user_restriction=True)).action_confirm()
|
||||||
|
|
||||||
|
def button_mark_done(self):
|
||||||
|
return super(MrpProduction, self.with_context(bypass_user_restriction=True)).button_mark_done()
|
||||||
@ -47,3 +47,10 @@ 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,
|
||||||
|
prefetch=False,
|
||||||
|
help="If checked, this user can see the Quality Checks button on Manufacturing Orders."
|
||||||
|
)
|
||||||
|
|||||||
@ -93,3 +93,9 @@ class ApprovalRequest(models.Model):
|
|||||||
if allowed_category_ids:
|
if allowed_category_ids:
|
||||||
domain = expression.AND([domain or [], [('category_id', 'in', allowed_category_ids)]])
|
domain = expression.AND([domain or [], [('category_id', 'in', allowed_category_ids)]])
|
||||||
return super()._search(domain, offset=offset, limit=limit, order=order)
|
return super()._search(domain, offset=offset, limit=limit, order=order)
|
||||||
|
|
||||||
|
def action_confirm(self):
|
||||||
|
return super(ApprovalRequest, self.with_context(bypass_user_restriction=True)).action_confirm()
|
||||||
|
|
||||||
|
def action_approve(self, approver=None):
|
||||||
|
return super(ApprovalRequest, self.with_context(bypass_user_restriction=True)).action_approve(approver=approver)
|
||||||
|
|||||||
@ -5,3 +5,6 @@ class SaleOrder(models.Model):
|
|||||||
|
|
||||||
def action_confirm(self):
|
def action_confirm(self):
|
||||||
return super(SaleOrder, self.with_context(bypass_user_restriction=True)).action_confirm()
|
return super(SaleOrder, self.with_context(bypass_user_restriction=True)).action_confirm()
|
||||||
|
|
||||||
|
def _action_confirm(self):
|
||||||
|
return super(SaleOrder, self.with_context(bypass_user_restriction=True))._action_confirm()
|
||||||
|
|||||||
18
models/stock_picking.py
Normal file
18
models/stock_picking.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
class StockPicking(models.Model):
|
||||||
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
def action_confirm(self):
|
||||||
|
return super(StockPicking, self.with_context(bypass_user_restriction=True)).action_confirm()
|
||||||
|
|
||||||
|
def button_validate(self):
|
||||||
|
return super(StockPicking, self.with_context(bypass_user_restriction=True)).button_validate()
|
||||||
20
views/mrp_production_views.xml
Normal file
20
views/mrp_production_views.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="mrp_production_view_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="priority">99999</field>
|
||||||
|
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
||||||
|
<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>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@ -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>
|
||||||
|
|||||||
20
views/stock_picking_views.xml
Normal file
20
views/stock_picking_views.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<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>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Loading…
Reference in New Issue
Block a user