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
1=== modified file 'account/account_invoice.py'
2--- account/account_invoice.py 2013-04-22 15:34:49 +0000
3+++ account/account_invoice.py 2013-05-16 08:43:14 +0000
4@@ -1416,7 +1416,7 @@
5 res['arch'] = etree.tostring(doc)
6 return res
7
8- 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):
9+ 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):
10 if context is None:
11 context = {}
12 company_id = company_id if company_id != None else context.get('company_id',False)
13@@ -1475,11 +1475,19 @@
14
15 company = self.pool.get('res.company').browse(cr, uid, company_id, context=context)
16 currency = self.pool.get('res.currency').browse(cr, uid, currency_id, context=context)
17+ currency_rate_obj = self.pool.get('res.currency.rate')
18+ if date_invoice:
19+ currency_id = currency_rate_obj.search(cr, uid, [('currency_id','=',currency_id),('name','<=',date_invoice)], limit=1, order='name desc')
20+ currency_rate = currency_rate_obj.read(cr, uid, currency_id[0], ['currency_id','rate'])
21+ if currency_rate:
22+ rate = currency_rate['rate'];
23+ else:
24+ rate = currency.rate
25
26 if company.currency_id.id != currency.id:
27 if type in ('in_invoice', 'in_refund'):
28 res_final['value']['price_unit'] = res.standard_price
29- new_price = res_final['value']['price_unit'] * currency.rate
30+ new_price = res_final['value']['price_unit'] * rate
31 res_final['value']['price_unit'] = new_price
32
33 if result['uos_id'] and result['uos_id'] != res.uom_id.id:
34@@ -1488,14 +1496,14 @@
35 res_final['value']['price_unit'] = new_price
36 return res_final
37
38- 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):
39+ 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):
40 if context is None:
41 context = {}
42 company_id = company_id if company_id != None else context.get('company_id',False)
43 context = dict(context)
44 context.update({'company_id': company_id})
45 warning = {}
46- res = self.product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, currency_id, context=context)
47+ 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)
48 if not uom:
49 res['value']['price_unit'] = 0.0
50 if product and uom:
51
52=== modified file 'account/account_invoice_view.xml'
53--- account/account_invoice_view.xml 2013-04-22 15:34:49 +0000
54+++ account/account_invoice_view.xml 2013-05-16 08:43:14 +0000
55@@ -48,7 +48,7 @@
56 <form string="Invoice Line" version="7.0">
57 <group>
58 <group>
59- <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)"/>
60+ <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)"/>
61 <label for="quantity"/>
62 <div>
63 <field name="quantity" class="oe_inline"/>
64@@ -203,7 +203,7 @@
65 domain="[('type','!=','view'), ('company_id', '=', parent.company_id)]"/>
66 <field name="quantity"/>
67 <field name="uos_id" groups="product.group_uom"
68- 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)"/>
69+ 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)"/>
70 <field name="price_unit"/>
71 <field name="discount" groups="sale.group_discount_per_so_line"/>
72 <field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"
73@@ -349,7 +349,7 @@
74 <field name="invoice_line" nolabel="1" widget="one2many_list" context="{'type': type}">
75 <tree string="Invoice Lines" editable="bottom">
76 <field name="product_id"
77- 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)"/>
78+ 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)"/>
79 <field name="name"/>
80 <field name="company_id" invisible="1"/>
81 <field name="account_id" groups="account.group_account_user"
82@@ -359,7 +359,7 @@
83 domain="[('type','!=','view'), ('company_id', '=', parent.company_id)]"/>
84 <field name="quantity"/>
85 <field name="uos_id" groups="product.group_uom"
86- 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)"/>
87+ 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)"/>
88 <field name="price_unit"/>
89 <field name="discount" groups="sale.group_discount_per_so_line"/>
90 <field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"

Subscribers

People subscribed via source and target branches

to all changes: