feat: Restrict stock picking validation for non-Quality users when pending quality checks exist.
This commit is contained in:
parent
07bb9367e1
commit
f783c381ca
@ -1 +1,2 @@
|
||||
from . import hooks
|
||||
from . import models
|
||||
1
models/__init__.py
Normal file
1
models/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from . import stock_picking
|
||||
22
models/stock_picking.py
Normal file
22
models/stock_picking.py
Normal file
@ -0,0 +1,22 @@
|
||||
from odoo import models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
class StockPicking(models.Model):
|
||||
_inherit = "stock.picking"
|
||||
|
||||
def check_quality(self):
|
||||
"""
|
||||
Override to prevent Access Error when non-Quality users allow validation
|
||||
triggers check_quality.
|
||||
"""
|
||||
# Check if user has Quality User group
|
||||
is_quality_user = self.env.user.has_group('quality.group_quality_user')
|
||||
|
||||
if not is_quality_user:
|
||||
# Check if there are checks to do
|
||||
checks = self._checks_to_do()
|
||||
if checks:
|
||||
# If there are pending checks and user is not allowed to do them, raise clear error
|
||||
raise UserError(_("You cannot validate this transfer because there are pending Quality Checks. Please ask a Quality User to perform them."))
|
||||
|
||||
return super().check_quality()
|
||||
Loading…
Reference in New Issue
Block a user