Skip to content

Commit

Permalink
[FIX]stock_ux:constrain check_cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
jcadhoc committed Apr 19, 2024
1 parent 6a85cd4 commit 010c465
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions stock_ux/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ def default_get(self, fields_list):

@api.constrains('state')
def check_cancel(self):
if self._context.get('cancel_from_order') or self.env.is_superuser():
return
if self.filtered(
lambda x: x.picking_id and x.state == 'cancel' and not self.user_has_groups('stock_ux.allow_picking_cancellation')):
raise ValidationError("Only User with 'Picking cancelation allow' rights can cancel pickings")
for rec in self:
if isinstance(rec.id, models.NewId):
if rec._context.get('cancel_from_order') or rec.env.is_superuser():
return
if rec.filtered(
lambda x: x.picking_id and x.state == 'cancel' and not rec.user_has_groups('stock_ux.allow_picking_cancellation')):
raise ValidationError("Only User with 'Picking cancelation allow' rights can cancel pickings")

0 comments on commit 010c465

Please sign in to comment.