From 7c28af4bd558f6307b0f09031b63e1a3fd558389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 27 Oct 2024 19:41:19 +0100 Subject: [PATCH] Do not convert invoiced quantity if sale or purchase has not unit Closes #13593 (grafted from 203c7f14ff6c4b230fe9bc0de42052d4b8cf90cb) --HG-- branch : 7.0 --- modules/purchase/purchase.py | 9 ++++++--- modules/sale/sale.py | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/purchase/purchase.py b/modules/purchase/purchase.py index c1c6c59b4f..8652a7b576 100644 --- a/modules/purchase/purchase.py +++ b/modules/purchase/purchase.py @@ -1773,9 +1773,12 @@ class Line(sequence_ordered(), ModelSQL, ModelView): if invoice_line.type != 'line': continue if invoice_line not in skips: - quantity += Uom.compute_qty( - invoice_line.unit or self.unit, invoice_line.quantity, - self.unit) + if self.unit: + quantity += Uom.compute_qty( + invoice_line.unit or self.unit, invoice_line.quantity, + self.unit) + else: + quantity += invoice_line.quantity return quantity def _get_invoice_line_moves(self): diff --git a/modules/sale/sale.py b/modules/sale/sale.py index 3f7f5b675d..6ef9f88b9a 100644 --- a/modules/sale/sale.py +++ b/modules/sale/sale.py @@ -1803,9 +1803,12 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView): if invoice_line.type != 'line': continue if invoice_line not in skips: - quantity += Uom.compute_qty( - invoice_line.unit or self.unit, invoice_line.quantity, - self.unit) + if self.unit: + quantity += Uom.compute_qty( + invoice_line.unit or self.unit, invoice_line.quantity, + self.unit) + else: + quantity += invoice_line.quantity return quantity def _get_invoice_line_moves(self):