[FIX] stock: Warning in picking on product with serial number

In stock.picking, in mode show detailed operation, add a product with
unique serial number tracking.

Before this commit, a warning about the qty is raised. This warning,
must be raised only if the qty is different from 1.
However this is not the case,
the warning is raised at each modification of the line.
This issue occurs since the rounding given to the float_compare is 0.0,
because self.move_id.product_id is not set.
Float_compare with a 0.0 rounding always return different, hence the bug.

Now, the warning is only raised when the qty is different from 1.

OPW-1932044

closes odoo/odoo#30651
This commit is contained in:
Jorge Pinna Puissant
2019-01-30 09:28:16 +00:00
parent 326a44c3f7
commit e13d449f31
+1 -1
View File
@@ -136,7 +136,7 @@ class StockMoveLine(models.Model):
"""
res = {}
if self.qty_done and self.product_id.tracking == 'serial':
if float_compare(self.qty_done, 1.0, precision_rounding=self.move_id.product_id.uom_id.rounding) != 0:
if float_compare(self.qty_done, 1.0, precision_rounding=self.product_id.uom_id.rounding) != 0:
message = _('You can only process 1.0 %s of products with unique serial number.') % self.product_id.uom_id.name
res['warning'] = {'title': _('Warning'), 'message': message}
return res