[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
This commit is contained in:
Martin Trigaux 2014-09-29 14:48:11 +02:00
parent 9066da3369
commit 066fbb6613
1 changed files with 8 additions and 4 deletions

View File

@ -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'],