changing company currency breaks analytic account

Bug #728560 reported by Aline (OpenERP)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 3

Bug Description

In trunk,

- create a db with "Project"
- go to company to change the currency (Administration / Companies / Companies)
- after changing of currency, go to analytic account named "Project" and try to change something (for example, the name) (Acounting / Configuration / Analytic accounting / Analytic Accounts)

-> bug

(if you can not see such menu, check if the user has an access to useabilit / analytic account)

Related branches

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

The problem is that the currency_id field on account.analytic.account is not a real "related" field to the company's currency.
I think the reason why a normal m2o field was used is because it is sometimes needed to set the currency_id to None/False on the analytic account, to let it be shared between different companies. This would not be possible on a real related field.
(Strangely, the currency_id field is currently required, though???)

So what we need is a sort of related field that can be set to null.

In order to fix it, I propose do the following:

- replace the currency_id m2o field by a function field with store={ 'res.company': ... } so that this function field is recomputed whenever the company is modified (a proper reverse function is needed here)

- when computing the function field (fnct), it should:
  1. if currency_id is currently set to NULL in the database, do nothing and leave it like that.
  2. else, return the currency_id of the company this account belongs to.

- the setter function (fnct_inv) should:
  1. if False/None is being written, update the database with NULL and return
  2. if a value is written, check if it is the same as the current company currency
  3. if the value is the same as current company, ignore it.
  4. if a different value is being written raise an error saying "An analytic account's currency must be the same as the currency of its owner company, or empty."

For all questions, please discuss with Quentin de Paoli.

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Low
milestone: none → 6.0.2
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Ashvin Rathod (OpenERP) (ara-tinyerp) wrote :

Hello Aline,

I have fixed the problem in lp:~openerp-dev/openobject-addons/trunk-bug-728560-ara branch. It will be merge soon with trunk addons.

@Olivier Dony: Thanks for explanation.

Revision ID: <email address hidden>
Revision No: 4515

Thanks,
ara

Changed in openobject-addons:
status: In Progress → Fix Committed
Changed in openobject-addons:
status: Fix Committed → Fix Released
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.