From a7765214649a4dc665545613495b90f837a4243a Mon Sep 17 00:00:00 2001 From: Salvi Angjeli <> Date: Mon, 1 Aug 2011 11:54:11 +0530 Subject: [PATCH 01/10] [FIX] account : problem with the compute currency of account move line of an invoice lp bug: https://launchpad.net/bugs/812261 fixed bzr revid: bde@tinyerp.com-20110801062411-8e1pff5uqyhhbwp5 --- addons/account/invoice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 09e8304340c..873b8852f19 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -863,7 +863,7 @@ class account_invoice(osv.osv): for t in totlines: if inv.currency_id.id != company_currency: amount_currency = cur_obj.compute(cr, uid, - company_currency, inv.currency_id.id, t[1]) + company_currency, inv.currency_id.id, t[1], context={'date':inv.date_invoice}) else: amount_currency = False From 4a3b8f91e63a914eadddd5dcee491d577d9b0bfb Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Tue, 2 Aug 2011 12:57:04 +0530 Subject: [PATCH 02/10] [IMP] Improved the context={'date':inv.date_invoice} by using context.copy and then passed the variable in context bzr revid: bde@tinyerp.com-20110802072704-7kpgux06o9fw1jft --- addons/account/invoice.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 873b8852f19..cab9e481d8d 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -861,9 +861,11 @@ class account_invoice(osv.osv): res_amount_currency = total_currency i = 0 for t in totlines: + ctx = context.copy() + ctx = {'date':inv.date_invoice} if inv.currency_id.id != company_currency: amount_currency = cur_obj.compute(cr, uid, - company_currency, inv.currency_id.id, t[1], context={'date':inv.date_invoice}) + company_currency, inv.currency_id.id, t[1]) else: amount_currency = False From 69f82288218c4c23b7d33e54ef4fb94d6c8c8da4 Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Mon, 8 Aug 2011 11:26:28 +0530 Subject: [PATCH 03/10] [IMP] improved the action_move_create method in invoice.py bzr revid: bde@tinyerp.com-20110808055628-7aiob4fwey7kk5ne --- addons/account/invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index cab9e481d8d..95fb3ede6ca 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -865,7 +865,7 @@ class account_invoice(osv.osv): ctx = {'date':inv.date_invoice} if inv.currency_id.id != company_currency: amount_currency = cur_obj.compute(cr, uid, - company_currency, inv.currency_id.id, t[1]) + company_currency, inv.currency_id.id, t[1], context=ctx) else: amount_currency = False From 38747ab6ca62926b3187f32300d81c56eddaea08 Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Fri, 12 Aug 2011 16:13:43 +0530 Subject: [PATCH 04/10] [IMP] the working of ctx variable in invoice.py bzr revid: bde@tinyerp.com-20110812104343-0e1z58s4whuy59ia --- addons/account/invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 95fb3ede6ca..2796bf712e1 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -862,7 +862,7 @@ class account_invoice(osv.osv): i = 0 for t in totlines: ctx = context.copy() - ctx = {'date':inv.date_invoice} + ctx.update({'date':inv.date_invoice}) if inv.currency_id.id != company_currency: amount_currency = cur_obj.compute(cr, uid, company_currency, inv.currency_id.id, t[1], context=ctx) From 53a520b4536e84d44deddbd079834a73e1d33fc4 Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Fri, 19 Aug 2011 11:20:29 +0530 Subject: [PATCH 05/10] [MERGE] merge with main addons bzr revid: bde@tinyerp.com-20110819055029-aa9kq7a1v6m9pj82 --- addons/account/invoice.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 2796bf712e1..356d9d6982e 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -1244,6 +1244,9 @@ account_invoice() class account_invoice_line(osv.osv): def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict): + + account_inv_obj = self.pool.get('account.invoice').browse(cr, uid, ids)[0] + print "account_inv_obj", account_inv_obj res = {} tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') @@ -1315,10 +1318,13 @@ class account_invoice_line(osv.osv): return res 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, company_id=None): + print ">>>>>>>>>>>", self, cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context, company_id if context is None: context = {} company_id = company_id if company_id != None else context.get('company_id',False) + print "company_id", company_id context = dict(context) + print "context", context context.update({'company_id': company_id}) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) @@ -1345,6 +1351,7 @@ class account_invoice_line(osv.osv): if not a: a = res.categ_id.property_account_expense_categ.id a = fpos_obj.map_account(cr, uid, fpos, a) + print "a", a if a: result['account_id'] = a @@ -1355,10 +1362,13 @@ class account_invoice_line(osv.osv): tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes) if type in ('in_invoice', 'in_refund'): + print "price_unit",price_unit result.update( {'price_unit': price_unit or res.standard_price,'invoice_line_tax_id': tax_id} ) else: + print "price_unitelseeeeee",res.list_price result.update({'price_unit': res.list_price, 'invoice_line_tax_id': tax_id}) result['name'] = res.partner_ref + print "result['name']", result['name'] domain = {} result['uos_id'] = res.uom_id.id or uom or False @@ -1376,18 +1386,31 @@ class account_invoice_line(osv.osv): company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) currency = self.pool.get('res.currency').browse(cr, uid, currency_id, context=context) + print "currency", currency + + print "company.currency_id.id", company.currency_id.id + print "currency.id", currency.id + print "res.standard_price", res.standard_price if company.currency_id.id != currency.id: if type in ('in_invoice', 'in_refund'): res_final['value']['price_unit'] = res.standard_price new_price = res_final['value']['price_unit'] * currency.rate res_final['value']['price_unit'] = new_price + print "res_final['value']['price_unit']", res_final['value']['price_unit'] + print "currency.rate", currency.rate if uom: + print "uom", uom + print "res.uom_id.category_id.id", res.uom_id.category_id.id + print "uom.category_id.id", uom.category_id.id + print "uom.factor_inv", uom.factor_inv uom = self.pool.get('product.uom').browse(cr, uid, uom, context=context) if res.uom_id.category_id.id == uom.category_id.id: new_price = res_final['value']['price_unit'] * uom.factor_inv res_final['value']['price_unit'] = new_price + print "res_final['value']['price_unit']", res_final['value']['price_unit'] + print "res_final", res_final return res_final def uos_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, company_id=None): From 01a10921244f638ac8e5c12b044d98da0f58b02e Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Fri, 9 Sep 2011 13:00:34 +0530 Subject: [PATCH 06/10] [MERGE] merge with main addons bzr revid: bde@tinyerp.com-20110909073034-y5hsoradsawni2j5 --- addons/account/invoice.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 356d9d6982e..8155feff896 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -1246,7 +1246,6 @@ class account_invoice_line(osv.osv): def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict): account_inv_obj = self.pool.get('account.invoice').browse(cr, uid, ids)[0] - print "account_inv_obj", account_inv_obj res = {} tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') @@ -1318,13 +1317,10 @@ class account_invoice_line(osv.osv): return res 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, company_id=None): - print ">>>>>>>>>>>", self, cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context, company_id if context is None: context = {} company_id = company_id if company_id != None else context.get('company_id',False) - print "company_id", company_id context = dict(context) - print "context", context context.update({'company_id': company_id}) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) @@ -1351,7 +1347,6 @@ class account_invoice_line(osv.osv): if not a: a = res.categ_id.property_account_expense_categ.id a = fpos_obj.map_account(cr, uid, fpos, a) - print "a", a if a: result['account_id'] = a @@ -1362,13 +1357,10 @@ class account_invoice_line(osv.osv): tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes) if type in ('in_invoice', 'in_refund'): - print "price_unit",price_unit result.update( {'price_unit': price_unit or res.standard_price,'invoice_line_tax_id': tax_id} ) else: - print "price_unitelseeeeee",res.list_price result.update({'price_unit': res.list_price, 'invoice_line_tax_id': tax_id}) result['name'] = res.partner_ref - print "result['name']", result['name'] domain = {} result['uos_id'] = res.uom_id.id or uom or False @@ -1386,31 +1378,18 @@ class account_invoice_line(osv.osv): company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) currency = self.pool.get('res.currency').browse(cr, uid, currency_id, context=context) - print "currency", currency - - print "company.currency_id.id", company.currency_id.id - print "currency.id", currency.id - print "res.standard_price", res.standard_price if company.currency_id.id != currency.id: if type in ('in_invoice', 'in_refund'): res_final['value']['price_unit'] = res.standard_price new_price = res_final['value']['price_unit'] * currency.rate res_final['value']['price_unit'] = new_price - print "res_final['value']['price_unit']", res_final['value']['price_unit'] - print "currency.rate", currency.rate if uom: - print "uom", uom - print "res.uom_id.category_id.id", res.uom_id.category_id.id - print "uom.category_id.id", uom.category_id.id - print "uom.factor_inv", uom.factor_inv uom = self.pool.get('product.uom').browse(cr, uid, uom, context=context) if res.uom_id.category_id.id == uom.category_id.id: new_price = res_final['value']['price_unit'] * uom.factor_inv res_final['value']['price_unit'] = new_price - print "res_final['value']['price_unit']", res_final['value']['price_unit'] - print "res_final", res_final return res_final def uos_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, company_id=None): From 2e992357158255f6a1b5c107ebe0cf922f298c21 Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Fri, 9 Sep 2011 15:20:10 +0530 Subject: [PATCH 07/10] [RESOLVED] conflicts resolved of account_ivoice.py bzr revid: bde@tinyerp.com-20110909095010-y9i5ifae00afkh8u --- addons/account/invoice.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 6016e0c8c32..aa0945427cf 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -864,11 +864,7 @@ class account_invoice(osv.osv): ctx = context.copy() ctx.update({'date':inv.date_invoice}) if inv.currency_id.id != company_currency: -<<<<<<< TREE amount_currency = cur_obj.compute(cr, uid, company_currency, inv.currency_id.id, t[1], context=ctx) -======= - company_currency, inv.currency_id.id, t[1], context=ctx) ->>>>>>> MERGE-SOURCE else: amount_currency = False From 382ffceb34dd26c7f0bee84bda55b71f0b3a6aea Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Tue, 13 Sep 2011 16:16:53 +0530 Subject: [PATCH 08/10] [IMP] account : improved the indentation and removed unnecessary code bzr revid: bde@tinyerp.com-20110913104653-z44g6r4zse3v4ibq --- addons/account/invoice.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index aa0945427cf..57fcb998df7 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -1,4 +1,4 @@ - # -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -1242,9 +1242,8 @@ class account_invoice(osv.osv): account_invoice() class account_invoice_line(osv.osv): - def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict): - account_inv_obj = self.pool.get('account.invoice').browse(cr, uid, ids)[0] + def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict): res = {} tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') From 055318610e20d68a96250cdfa9ddb8a13568931f Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Tue, 13 Sep 2011 18:41:02 +0530 Subject: [PATCH 09/10] [IMP] account : defined context above for loop in invoice.py bzr revid: bde@tinyerp.com-20110913131102-qrkb4b8dhkjmxgsa --- addons/account/invoice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 57fcb998df7..efbf3605059 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -860,9 +860,9 @@ class account_invoice(osv.osv): if totlines: res_amount_currency = total_currency i = 0 + ctx = context.copy() + ctx.update({'date':inv.date_invoice}) for t in totlines: - ctx = context.copy() - ctx.update({'date':inv.date_invoice}) if inv.currency_id.id != company_currency: amount_currency = cur_obj.compute(cr, uid, company_currency, inv.currency_id.id, t[1], context=ctx) else: From 9ae0f3a2933cdfbb6fce4d1dc6089b93412d9ac0 Mon Sep 17 00:00:00 2001 From: "Mustufa Rangwala (OpenERP)" Date: Wed, 14 Sep 2011 10:21:21 +0530 Subject: [PATCH 10/10] [FIX] Account: Action move create remove ctx as it is already defined bzr revid: mra@tinyerp.com-20110914045121-skvymznk4ikxg7j0 --- addons/account/invoice.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index efbf3605059..44aea3466e6 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -860,8 +860,7 @@ class account_invoice(osv.osv): if totlines: res_amount_currency = total_currency i = 0 - ctx = context.copy() - ctx.update({'date':inv.date_invoice}) + ctx.update({'date': inv.date_invoice}) for t in totlines: if inv.currency_id.id != company_currency: amount_currency = cur_obj.compute(cr, uid, company_currency, inv.currency_id.id, t[1], context=ctx)