From 8bdccc5cd26cea8a6b180b8953414cc4f55e1ff8 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Fri, 17 May 2013 09:35:16 +0200 Subject: [PATCH 1/2] [FIX] work around bug preventing to validate invoices in multicompany setting lp bug: https://launchpad.net/bugs/1111298 fixed bzr revid: alexandre.fayolle@camptocamp.com-20130517073516-yko5zp0j8zlopq2d --- addons/account/account_invoice.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 09b18da6e31..79ee5b3fe88 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -764,6 +764,8 @@ class account_invoice(osv.osv): return move_lines def check_tax_lines(self, cr, uid, inv, compute_taxes, ait_obj): + # work around bug lp:1111298 : problem in multicompany setting when accessing inv.company_id.currency_id + company_currency = self.pool['res.company'].browse(cr, uid, inv.company_id.id).currency_id if not inv.tax_line: for tax in compute_taxes.values(): ait_obj.create(cr, uid, tax) @@ -777,7 +779,7 @@ class account_invoice(osv.osv): if not key in compute_taxes: raise osv.except_osv(_('Warning!'), _('Global taxes defined, but they are not in invoice lines !')) base = compute_taxes[key]['base'] - if abs(base - tax.base) > inv.company_id.currency_id.rounding: + if abs(base - tax.base) > company_currency.rounding: raise osv.except_osv(_('Warning!'), _('Tax base different!\nClick on compute to update the tax base.')) for key in compute_taxes: if not key in tax_key: @@ -864,7 +866,8 @@ class account_invoice(osv.osv): ctx.update({'lang': inv.partner_id.lang}) if not inv.date_invoice: self.write(cr, uid, [inv.id], {'date_invoice': fields.date.context_today(self,cr,uid,context=context)}, context=ctx) - company_currency = inv.company_id.currency_id.id + # work around bug lp:1111298 : problem in multicompany setting when accessing inv.company_id.currency_id + company_currency = self.pool['res.company'].browse(cr, uid, inv.company_id.id).currency_id.id # create the analytical lines # one move line per invoice line iml = self._get_analytic_lines(cr, uid, inv.id, context=ctx) From b0ee634dec85e2513430b567559e52b9e4d60026 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Fri, 17 May 2013 10:00:31 +0200 Subject: [PATCH 2/2] [FIX] some missed access to currency_id through company_id bzr revid: alexandre.fayolle@camptocamp.com-20130517080031-7j72snb9mdv91cto --- addons/account/account_invoice.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 79ee5b3fe88..057947205f0 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -717,7 +717,7 @@ class account_invoice(osv.osv): inv = self.browse(cr, uid, id) cur_obj = self.pool.get('res.currency') - company_currency = inv.company_id.currency_id.id + company_currency = self.pool['res.company'].browse(cr, uid, inv.company_id.id).currency_id.id if inv.type in ('out_invoice', 'in_refund'): sign = 1 else: @@ -764,7 +764,6 @@ class account_invoice(osv.osv): return move_lines def check_tax_lines(self, cr, uid, inv, compute_taxes, ait_obj): - # work around bug lp:1111298 : problem in multicompany setting when accessing inv.company_id.currency_id company_currency = self.pool['res.company'].browse(cr, uid, inv.company_id.id).currency_id if not inv.tax_line: for tax in compute_taxes.values(): @@ -866,7 +865,6 @@ class account_invoice(osv.osv): ctx.update({'lang': inv.partner_id.lang}) if not inv.date_invoice: self.write(cr, uid, [inv.id], {'date_invoice': fields.date.context_today(self,cr,uid,context=context)}, context=ctx) - # work around bug lp:1111298 : problem in multicompany setting when accessing inv.company_id.currency_id company_currency = self.pool['res.company'].browse(cr, uid, inv.company_id.id).currency_id.id # create the analytical lines # one move line per invoice line @@ -1517,8 +1515,7 @@ class account_invoice_line(osv.osv): if context is None: context = {} inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context) - company_currency = inv.company_id.currency_id.id - + 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: @@ -1663,8 +1660,7 @@ class account_invoice_tax(osv.osv): cur_obj = self.pool.get('res.currency') inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context) cur = inv.currency_id - company_currency = inv.company_id.currency_id.id - + company_currency = self.pool['res.company'].browse(cr, uid, inv.company_id.id).currency_id.id for line in inv.invoice_line: for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, (line.price_unit* (1-(line.discount or 0.0)/100.0)), line.quantity, line.product_id, inv.partner_id)['taxes']: val={}