From 75fa619f7c3d2c14c4867e40ce061c02dbb6a0a5 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Tue, 17 Sep 2019 13:57:04 +0000 Subject: [PATCH] [FIX] repair: warning if negative quantity Before this commit, you can start a repair order with negative value into its operations (who will cause a dead end when user will try to end it). So, now a check is done when user tries to start it. closes odoo/odoo#37045 Signed-off-by: Simon Lejeune (sle) --- addons/repair/models/repair.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py index 3a1fe59b63c..0e4cb922cc8 100644 --- a/addons/repair/models/repair.py +++ b/addons/repair/models/repair.py @@ -199,6 +199,8 @@ class Repair(models.Model): def action_validate(self): self.ensure_one() + if self.filtered(lambda repair: any(op.product_uom_qty < 0 for op in repair.operations)): + raise UserError(_("You can not enter negative quantities.")) if self.product_id.type == 'consu': return self.action_repair_confirm() precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')