Merge lp:~openerp-dev/openobject-addons/trunk-bug-1102592-nco into lp:openobject-addons

Proposed by Nimesh Contractor(Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-1102592-nco
Merge into: lp:openobject-addons
Diff against target: 90 lines (+16/-8)
2 files modified
account/account_invoice.py (+12/-4)
account/account_invoice_view.xml (+4/-4)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-1102592-nco
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+164090@code.launchpad.net

Description of the change

Hello,

 Fix multi-currency computation by date.

Thanks,
Nimesh.

To post a comment you must log in.

Unmerged revisions

8705. By Nimesh Contractor(Open ERP)

[IMP] improve code.

8704. By Ishwar Malvi(OpenERP)

[FIX] multi-currency computation by date.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py 2013-04-22 15:34:49 +0000
+++ account/account_invoice.py 2013-05-16 08:43:14 +0000
@@ -1416,7 +1416,7 @@
1416 res['arch'] = etree.tostring(doc)1416 res['arch'] = etree.tostring(doc)
1417 return res1417 return res
14181418
1419 def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None):1419 def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None, date_invoice=None):
1420 if context is None:1420 if context is None:
1421 context = {}1421 context = {}
1422 company_id = company_id if company_id != None else context.get('company_id',False)1422 company_id = company_id if company_id != None else context.get('company_id',False)
@@ -1475,11 +1475,19 @@
14751475
1476 company = self.pool.get('res.company').browse(cr, uid, company_id, context=context)1476 company = self.pool.get('res.company').browse(cr, uid, company_id, context=context)
1477 currency = self.pool.get('res.currency').browse(cr, uid, currency_id, context=context)1477 currency = self.pool.get('res.currency').browse(cr, uid, currency_id, context=context)
1478 currency_rate_obj = self.pool.get('res.currency.rate')
1479 if date_invoice:
1480 currency_id = currency_rate_obj.search(cr, uid, [('currency_id','=',currency_id),('name','<=',date_invoice)], limit=1, order='name desc')
1481 currency_rate = currency_rate_obj.read(cr, uid, currency_id[0], ['currency_id','rate'])
1482 if currency_rate:
1483 rate = currency_rate['rate'];
1484 else:
1485 rate = currency.rate
14781486
1479 if company.currency_id.id != currency.id:1487 if company.currency_id.id != currency.id:
1480 if type in ('in_invoice', 'in_refund'):1488 if type in ('in_invoice', 'in_refund'):
1481 res_final['value']['price_unit'] = res.standard_price1489 res_final['value']['price_unit'] = res.standard_price
1482 new_price = res_final['value']['price_unit'] * currency.rate1490 new_price = res_final['value']['price_unit'] * rate
1483 res_final['value']['price_unit'] = new_price1491 res_final['value']['price_unit'] = new_price
14841492
1485 if result['uos_id'] and result['uos_id'] != res.uom_id.id:1493 if result['uos_id'] and result['uos_id'] != res.uom_id.id:
@@ -1488,14 +1496,14 @@
1488 res_final['value']['price_unit'] = new_price1496 res_final['value']['price_unit'] = new_price
1489 return res_final1497 return res_final
14901498
1491 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, currency_id=False, context=None, company_id=None):1499 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, currency_id=False, context=None, company_id=None, date_invoice=None):
1492 if context is None:1500 if context is None:
1493 context = {}1501 context = {}
1494 company_id = company_id if company_id != None else context.get('company_id',False)1502 company_id = company_id if company_id != None else context.get('company_id',False)
1495 context = dict(context)1503 context = dict(context)
1496 context.update({'company_id': company_id})1504 context.update({'company_id': company_id})
1497 warning = {}1505 warning = {}
1498 res = self.product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, currency_id, context=context)1506 res = self.product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, currency_id, context=context, date_invoice=date_invoice)
1499 if not uom:1507 if not uom:
1500 res['value']['price_unit'] = 0.01508 res['value']['price_unit'] = 0.0
1501 if product and uom:1509 if product and uom:
15021510
=== modified file 'account/account_invoice_view.xml'
--- account/account_invoice_view.xml 2013-04-22 15:34:49 +0000
+++ account/account_invoice_view.xml 2013-05-16 08:43:14 +0000
@@ -48,7 +48,7 @@
48 <form string="Invoice Line" version="7.0">48 <form string="Invoice Line" version="7.0">
49 <group>49 <group>
50 <group>50 <group>
51 <field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>51 <field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id, parent.date_invoice)"/>
52 <label for="quantity"/>52 <label for="quantity"/>
53 <div>53 <div>
54 <field name="quantity" class="oe_inline"/>54 <field name="quantity" class="oe_inline"/>
@@ -203,7 +203,7 @@
203 domain="[('type','!=','view'), ('company_id', '=', parent.company_id)]"/>203 domain="[('type','!=','view'), ('company_id', '=', parent.company_id)]"/>
204 <field name="quantity"/>204 <field name="quantity"/>
205 <field name="uos_id" groups="product.group_uom"205 <field name="uos_id" groups="product.group_uom"
206 on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>206 on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id, parent.date_invoice)"/>
207 <field name="price_unit"/>207 <field name="price_unit"/>
208 <field name="discount" groups="sale.group_discount_per_so_line"/>208 <field name="discount" groups="sale.group_discount_per_so_line"/>
209 <field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"209 <field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"
@@ -349,7 +349,7 @@
349 <field name="invoice_line" nolabel="1" widget="one2many_list" context="{'type': type}">349 <field name="invoice_line" nolabel="1" widget="one2many_list" context="{'type': type}">
350 <tree string="Invoice Lines" editable="bottom">350 <tree string="Invoice Lines" editable="bottom">
351 <field name="product_id"351 <field name="product_id"
352 on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>352 on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id, parent.date_invoice)"/>
353 <field name="name"/>353 <field name="name"/>
354 <field name="company_id" invisible="1"/>354 <field name="company_id" invisible="1"/>
355 <field name="account_id" groups="account.group_account_user"355 <field name="account_id" groups="account.group_account_user"
@@ -359,7 +359,7 @@
359 domain="[('type','!=','view'), ('company_id', '=', parent.company_id)]"/>359 domain="[('type','!=','view'), ('company_id', '=', parent.company_id)]"/>
360 <field name="quantity"/>360 <field name="quantity"/>
361 <field name="uos_id" groups="product.group_uom"361 <field name="uos_id" groups="product.group_uom"
362 on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>362 on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id, parent.date_invoice)"/>
363 <field name="price_unit"/>363 <field name="price_unit"/>
364 <field name="discount" groups="sale.group_discount_per_so_line"/>364 <field name="discount" groups="sale.group_discount_per_so_line"/>
365 <field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"365 <field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"

Subscribers

People subscribed via source and target branches

to all changes: