From b2f1c764cd8f89ac6eeaec21c1827df6c4e817b9 Mon Sep 17 00:00:00 2001 From: Ruchir Shukla Date: Sat, 21 Jun 2014 11:48:42 +0530 Subject: [PATCH] [FIX] account_anglo_saxon: avoid duplication of price difference lines When computing the price difference lines, in move_line_get of account_anglo_saxon, we loop on the result of super call for each lines (n * n times) to compute the price difference. The product_id was used to match the returned line and the original invoice line. This was wrong as we could get several lines with the same product_id (and then get n * n price difference lines). This patch adds the line id to the result of move_line_get (from account) so that account_anglo_saxon can filter more efficiently and only get one price difference per invoice line. Fixes #704 --- addons/account/account_invoice.py | 3 +-- addons/account_anglo_saxon/invoice.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 00d0b0d57a0..7677c212781 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1568,8 +1568,7 @@ class account_invoice_line(osv.osv): company_currency = self.pool['res.company'].browse(cr, uid, inv.company_id.id).currency_id.id for line in inv.invoice_line: mres = self.move_line_get_item(cr, uid, line, context) - if not mres: - continue + mres['invl_id'] = line.id res.append(mres) tax_code_found= False for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index 0530abf1386..3b859472774 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -119,7 +119,7 @@ class account_invoice_line(osv.osv): account_prec = decimal_precision.precision_get(cr, uid, 'Account') # calculate and write down the possible price difference between invoice price and product price for line in res: - if a == line['account_id'] and i_line.product_id.id == line['product_id']: + if line.get('invl_id', 0) == i_line.id and a == line['account_id']: uom = i_line.product_id.uos_id or i_line.product_id.uom_id standard_price = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.standard_price, i_line.uos_id.id) if inv.currency_id.id != company_currency: