From 0cf4a7af79d15126cda8e21f62d4f084e2817534 Mon Sep 17 00:00:00 2001 From: Guillem Barba Date: Mon, 26 Jan 2015 11:39:01 +0100 Subject: [PATCH] Support mixed invoice type by line in invoiced quantity calculation issue4410 review10751002 --- CHANGELOG | 2 ++ purchase.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 15e02b276c..5def31ef49 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ * Use TaxableMixin +* Support mixed invoice type by line in invoiced quantity calculation + Version 3.4.0 - 2014-10-20 * Bug fixes (see mercurial logs for details) * Confirmed state split into Confirmed and Processing diff --git a/purchase.py b/purchase.py index 23235bd1df..ad1019755d 100644 --- a/purchase.py +++ b/purchase.py @@ -1227,8 +1227,15 @@ class PurchaseLine(ModelSQL, ModelView): if old_invoice_line.type != 'line': continue if old_invoice_line.id not in skip_ids: + if old_invoice_line.invoice: + old_invoice_type = old_invoice_line.invoice.type + else: + old_invoice_type = old_invoice_line.invoice_type + + sign = 1 if old_invoice_type == invoice_type else -1 + quantity -= Uom.compute_qty(old_invoice_line.unit, - old_invoice_line.quantity, self.unit) + sign * old_invoice_line.quantity, self.unit) rounding = self.unit.rounding if self.unit else 0.01 invoice_line.quantity = Uom.round(quantity, rounding)