Wrong currency on bank statement in multi company setup

Bug #1136373 reported by Danijel Ilievski
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Committed
Medium
OpenERP R&D Addons Team 3

Bug Description

The currency on the bank statement does not reflect the currency of the journal selected but it displays the currency of the company the current user is working in.

Steps to reproduce:
1. create new database with demo data

2. install Accounting & Finance module

3. go to Settings >> General Settings and enable 'Manage multiple companies'

4. go to Settings >> Companies >> edit 'OpenERP Editor' and change the currency to RUB; do the same for 'OpenERP IN' and change the currency to INR

5. go to Settings >> Accounting and set any chart of accounts to 'OpenERP Editor' and 'OpenERP IN' one at a time. I used the same CoA for both companies, but different CoAs can be used as that doesn't matter in this case

6. create user login 'UserA' and under Access Rights grant it Accountant role to the accounting module; also enable 'Multiple Companies' setting; set Company field to 'OpenERP Editor' and add 'OpenERP Editor' to Allowed Companies.

7. log in as UserA and create a new bank statement but for 'OpenERP IN'

8. to do so, change the journal to 'OpenERP India Bank (INR)', observe that the Currency field has changed to INR which is correct behavior for now (see screenshot 1).

9. optionally change the date/period and add line items

10. save the bank statement and note that the Currency has changed to RUB, which is the default company for UserA (!) (see screenshot 2)

I've located the problem in code file 'account_bank_statement.py', in '_currency' method.

Currently the code checks, if there is a currency specified for the journal. If not, it takes the currency of the company of the user currently logged in. It doesn't take into account the currency of the company the journal is linked to.

The current code block looks like this (line 73):
--------------------------------------------------------------------------------
default_currency = res_users_obj.browse(cursor, user, user, context=context).company_id.currency_id
        for statement in self.browse(cursor, user, ids, context=context):
            currency = statement.journal_id.currency
            if not currency:
                currency = default_currency
--------------------------------------------------------------------------------

And according to my opinion it should look like this:
--------------------------------------------------------------------------------
default_currency = res_users_obj.browse(cursor, user, user, context=context).company_id.currency_id
        for statement in self.browse(cursor, user, ids, context=context):
            currency = statement.journal_id.currency
            if not currency:
                 currency = statement.journal_id.company_id.currency_id # get the currency of the company the journal is for
            if not currency:
                currency = default_currency
--------------------------------------------------------------------------------

Hope this helps,
Danijel

Related branches

Revision history for this message
Danijel Ilievski (danijel-san) wrote :
Revision history for this message
Danijel Ilievski (danijel-san) wrote :
description: updated
description: updated
Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Medium
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
Danijel Ilievski (danijel-san) wrote :

Hi Priyanka,

I still can reproduce this bug in version 7.0-20130318-002339. Can you please tell me where the fix has been committed to?

Thank you.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.