From 98c339c07a25c5ce5b11c26ab4e81b8ceb3dfac2 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Fri, 4 Dec 2009 15:59:03 +0530 Subject: [PATCH] [IMP]: implement multi-currency invoice creation bzr revid: mga@tinyerp.com-20091204102903-lbawyu0qopwfypc0 --- addons/account/account_invoice_view.xml | 4 ++-- addons/account/invoice.py | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 309b67c0299..aff83eaf918 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -52,7 +52,7 @@
- + @@ -156,7 +156,7 @@ - + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 0716d092ffe..2af3bbc8d5b 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -68,8 +68,6 @@ class account_invoice(osv.osv): res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'sale')), ('company_id', '=', company_id)], limit=1) - print "XXX",context - print "XXX",res if res: return res[0] else: @@ -1104,7 +1102,7 @@ class account_invoice_line(osv.osv): price_unit = price_unit - tax['amount'] return {'price_unit': price_unit,'invoice_line_tax_id': tax_id} - def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, context=None): + def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) @@ -1214,10 +1212,21 @@ class account_invoice_line(osv.osv): res2 = res.uom_id.category_id.id if res2 : domain = {'uos_id':[('category_id','=',res2 )]} - + prod_pool=self.pool.get('product.product') - result['categ_id'] = res.categ_id.id - return {'value':result, 'domain':domain} + result['categ_id'] = res.categ_id.id + res_final = {'value':result, 'domain':domain} + + if not company_id and not currency_id: + return res_final + + company = self.pool.get('res.company').browse(cr, uid, company_id) + currency = self.pool.get('res.currency').browse(cr, uid, currency_id) + + if company.currency_id.id != currency.id and currency.company_id.id == company.id: + new_price = res_final['value']['price_unit'] * currency.rate + res_final['value']['price_unit'] = new_price + return res_final def move_line_get(self, cr, uid, invoice_id, context=None): res = []