diff --git a/purchase.py b/purchase.py index ac2477aa7c..de74312319 100644 --- a/purchase.py +++ b/purchase.py @@ -1291,11 +1291,12 @@ class PurchaseLine(ModelSQL, ModelView): if old_invoice_line.id not in skip_ids: quantity -= Uom.compute_qty(old_invoice_line.unit, old_invoice_line.quantity, self.unit) - invoice_line.quantity = quantity rounding = self.unit.rounding if self.unit else 0 - if invoice_line.quantity < rounding: + invoice_line.quantity = Uom.round(quantity, rounding) + if invoice_line.quantity <= 0: return [] + invoice_line.unit = self.unit invoice_line.product = self.product invoice_line.unit_price = self.unit_price @@ -1349,8 +1350,11 @@ class PurchaseLine(ModelSQL, ModelView): if move not in skip: quantity -= Uom.compute_qty(move.uom, move.quantity, self.unit) - if quantity < self.unit.rounding: + + quantity = Uom.round(quantity, self.unit.rounding) + if quantity <= 0: return + if not self.purchase.party.supplier_location: self.raise_user_error('supplier_location_required', { 'purchase': self.purchase.rec_name,