From c0909c0f643e9f0ff06c40d22b44f9e7b73f9d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 23 Mar 2013 15:38:32 +0100 Subject: [PATCH] Use origin reference on Move issue2642 review717002 --- invoice.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/invoice.py b/invoice.py index 11f42b1d65..5858c664eb 100644 --- a/invoice.py +++ b/invoice.py @@ -47,7 +47,10 @@ class InvoiceLine: return result def get_move_line(self): - Move = Pool().get('stock.move') + pool = Pool() + Move = pool.get('stock.move') + PurchaseLine = pool.get('purchase.line') + SaleLine = pool.get('sale.line') result = super(InvoiceLine, self).get_move_line() @@ -60,14 +63,9 @@ class InvoiceLine: moves = [] # other types will get current cost price - if self.invoice.type == 'in_invoice': - moves = [move for purchase_line in self.purchase_lines - for move in purchase_line.moves - if move.state == 'done'] - elif self.invoice.type == 'out_invoice': - moves = [move for sale_line in self.sale_lines - for move in sale_line.moves - if move.state == 'done'] + if isinstance(self.origin, (PurchaseLine, SaleLine)): + moves = [move for move in self.origin.moves + if move.state == 'done'] if self.invoice.type == 'in_invoice': type_ = 'in_supplier' elif self.invoice.type == 'out_invoice':