From d8cb03642e367f34717475db29f532d8e074d03c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 26 Mar 2020 00:11:06 +0100 Subject: [PATCH] Skip canceled move and invoice when computing quantity This ensures that newly recreated invoices or moves are still linked as quantity will be lower. issue9032 review258971002 --- account.py | 5 +++-- stock.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/account.py b/account.py index ad0071ebb4..1617196df5 100644 --- a/account.py +++ b/account.py @@ -31,8 +31,9 @@ class InvoiceLine(metaclass=PoolMeta): Uom = pool.get('product.uom') quantity = 0 for stock_move in self.stock_moves: - quantity += Uom.compute_qty(stock_move.uom, stock_move.quantity, - self.unit) + if stock_move.state != 'cancel': + quantity += Uom.compute_qty( + stock_move.uom, stock_move.quantity, self.unit) return quantity @classmethod diff --git a/stock.py b/stock.py index 918d0b4322..da29e8ecc8 100644 --- a/stock.py +++ b/stock.py @@ -17,8 +17,9 @@ class Move(metaclass=PoolMeta): Uom = pool.get('product.uom') quantity = 0 for invoice_line in self.invoice_lines: - quantity += Uom.compute_qty(invoice_line.unit, - invoice_line.quantity, self.uom) + if invoice_line.invoice_state != 'cancel': + quantity += Uom.compute_qty( + invoice_line.unit, invoice_line.quantity, self.uom) return quantity @classmethod