From 066fbb66132724b23129071193785e33d0c2bdd9 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 29 Sep 2014 14:48:11 +0200 Subject: [PATCH] [FIX] account_anglo_saxon: price difference, discount and taxes When computing the price difference amount do not integrate the eventual discount and taxes included in the price. Otherwise the total of the generated accounting enty would be higher than the total of the invoice. opw 611350 --- addons/account_anglo_saxon/invoice.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index 8a816b0c962..ec455fc49d8 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -110,14 +110,18 @@ class account_invoice_line(osv.osv): if inv.currency_id.id != company_currency: standard_price = self.pool.get('res.currency').compute(cr, uid, company_currency, inv.currency_id.id, standard_price, context={'date': inv.date_invoice}) if standard_price != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc: - price_diff = round(i_line.price_unit - standard_price, account_prec) - line.update({'price': round(standard_price * line['quantity'], account_prec)}) + # price with discount and without tax included + price_unit = self.pool['account.tax'].compute_all(cr, uid, line['taxes'], + i_line.price_unit * (1-(i_line.discount or 0.0)/100.0), line['quantity'])['total'] + price_line = round(standard_price * line['quantity'], account_prec) + price_diff = round(price_unit - price_line, account_prec) + line.update({'price': price_line}) diff_res.append({ 'type':'src', 'name': i_line.name[:64], - 'price_unit':price_diff, + 'price_unit': round(price_diff / line['quantity'], account_prec), 'quantity':line['quantity'], - 'price': round(price_diff * line['quantity'], account_prec), + 'price': price_diff, 'account_id':acc, 'product_id':line['product_id'], 'uos_id':line['uos_id'],