From 7d19b0fd1e754d4b7dc020f618c8e5410a13205d Mon Sep 17 00:00:00 2001 From: qdp Date: Tue, 27 Jan 2009 11:06:08 +0100 Subject: [PATCH] [FIX] bugfixed the incoming tax on onchange of product in supplier invoice and refund [FIX] bugfixed the invoice validation: if we were setting up a customer invoice with a tax in one line and validated it without pressing the compute button first, it was creating the tax line twice. bzr revid: qdp@tinyerp.com-20090127100608-u942qhh9egpa420f --- addons/account/invoice.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 2e5550325b7..de343eedfd1 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -483,13 +483,9 @@ class account_invoice(osv.osv): cur_obj = self.pool.get('res.currency') for inv in self.browse(cr, uid, ids): - if not inv.tax_line: - self.button_compute(cr, uid, [inv.id], context={}, set_total=False) if inv.move_id: continue - if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding/2.0): - raise osv.except_osv(_('Bad total !'), _('Please verify the price of the invoice !\nThe real total does not match the computed total.')) if not inv.date_invoice: self.write(cr, uid, [inv.id], {'date_invoice':time.strftime('%Y-%m-%d')}) company_currency = inv.company_id.currency_id.id @@ -519,6 +515,9 @@ class account_invoice(osv.osv): if not key in tax_key: raise osv.except_osv(_('Warning !'), _('Taxes missing !')) + if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding/2.0): + raise osv.except_osv(_('Bad total !'), _('Please verify the price of the invoice !\nThe real total does not match the computed total.')) + # one move line per tax line iml += ait_obj.move_line_get(cr, uid, inv.id) @@ -986,7 +985,7 @@ class account_invoice_line(osv.osv): taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid,a).tax_ids or False) tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) else: - taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid,a).tax_ids or False) + taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid,a).tax_ids or False) tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) if type in ('in_invoice', 'in_refund'): to_update = self.product_id_change_unit_price_inv(cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=context)