23 lines
882 B
Python
23 lines
882 B
Python
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()
|