changing company currency breaks analytic account
Bug #728560 reported by
Aline (OpenERP)
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
lp:~openerp-dev/openobject-addons/trunk-bug-728560-ara
- OpenERP buildbot (community): Needs Fixing
- Mustufa Rangwala (Open ERP) (community): Approve
- Ashvin Rathod (OpenERP) (community): Needs Resubmitting
- qdp (OpenERP): Pending requested
-
Diff: 76 lines (+30/-9)1 file modifiedanalytic/analytic.py (+30/-9)
Changed in openobject-addons: | |
status: | Confirmed → In Progress |
Changed in openobject-addons: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
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.