← Back to team overview

openerp-community team mailing list archive

Multi-company Multi-currency Multi-rate

 

Hi all!

Consider the following company structure where COM_A is a consolidated
company with two child companies COM_B1 and COM_B2:

COM_A
+-> COM_B1
+-> COM_B2

When all companies utilize the same base currency IDR, generating a
consolidated financial report at COM_A such as a consolidated balance
sheet has no problem at all because all move lines in each company have
their credits and debits expressed in the base currency IDR.

But now consider the case when the companies do not share a common base
currency such as:

COM_A: IDR
+-> COM_B1: USD
+-> COM_B2: USD

In this case, when generating a consolidated financial report at COM_A
such as consolidated balance sheet, a currency conversion needs to be
made. Looking at how OpenERP balance sheet works, this case is not
handled as can be seen in the code below taken from version 6.0:

account/account.py:method __compute @ line 228:
for child in current.child_id:
  if (child.company_id.currency_id.id
      == current.company_id.currency_id.id):
    sums[current.id][fn] += sums[child.id][fn]
  else:
    sums[current.id][fn] += currency_obj.compute(cr, uid,
                                                 child.company_id.currency_id.id,
                                                 current.company_id.currency_id.id,
                                                 sums[child.id][fn],
                                                 context=context)

[SERVER]/bin/addons/base/res/res_currency.py:method compute @ line 106:
rate = self._get_conversion_rate(cr, uid, from_currency, to_currency, context=context)

[SERVER]/bin/addons/base/res/res_currency.py:method _get_conversion_rate @ line 92:
return to_currency.rate/from_currency.rate

[SERVER]/bin/addons/base/res/res_currency.py:method _current_rate @ line 30:
cr.execute("SELECT currency_id, rate"
           "FROM res_currency_rate"
           "WHERE currency_id = %s AND name <= %s"
           "ORDER BY name desc"
           "LIMIT 1" ,(id, date))

But, field rate from table res_currency_rate is actually a conversion
rate to the base currency of a certain company.

So, when a consolidated account ACC_A having IDR as base currency and
with a consolidated child account ACC_B1 having USD as base currency is
encountered in method __compute of account.py, the rate would always be
1 in method compute of res_currency.py, right?

What is needed a currency conversion logic from a child company to a
parent company, no?

Has anyone already worked on this issue?

Thank you.

-- 
Best regards,
Tadeus Prastowo (Free Software specialist and developer)

i n f i n i t y . s o l u t i o n
PT. Vikasa Infinity Anugrah (www.infi-nity.com)
Wisma Presisi 2nd Floor, Jalan Taman Aries Blok A1 No. 1,
Meruya Utara - Kembangan, Jakarta Barat 11620 - INDONESIA
t: +62 (21) 5316 4796 f: +62 (21) 5316 4797 m:+62 878 08305292



Follow ups