diff --git a/stock_ux/models/stock_picking.py b/stock_ux/models/stock_picking.py index abf536e4..efa60a53 100644 --- a/stock_ux/models/stock_picking.py +++ b/stock_ux/models/stock_picking.py @@ -154,3 +154,9 @@ def _check_backorder(self): pack.qty_done, pack.product_id.uom_id) return any(quantity_done[x] < quantity_todo.get(x, 0) for x in quantity_done) + + @api.constrains('state') + def check_cancel(self): + if self.filtered( + lambda x: 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")