chart of account tree - how to re-arrange?

Asked by Jan Verlaan

I am building a new chart of account. In the account tree my items are not in sequence as
1
-->10
2
-->20
but are unexpectedly changing to
2
-->20
1
-->10
thus into the wrong sequence.

I have searched around and found that the tablefields parent_right and parent_left are calculated and influencing, but could not find how I can influence that behavior.

Is my only option to create a XML in the right sequence so when installing the chart module the table is populated in right sequence or do I have a second option to influence that behavior?
How to add general-ledger records later on so the can fall in the right sequence?

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Verlaan
Solved:
Last query:
Last reply:
Revision history for this message
Jan Verlaan (jan-verlaan) said :
#1

A vast behavior I found is that when a new general ledger record is created via the client it is always displayed at the top of the selected view where I would like it to display.
A better option would be when it is displayed in sequence of the numbering.

Revision history for this message
Jan Verlaan (jan-verlaan) said :
#2

Found in account.py
class account_account(osv.osv):
    _order = "parent_left"
    _parent_order = "code"
    _name = "account.account"

As far I can see there is no way to manually influence the sequence of the fields in the general ledger only then when importing first time a country specific GL module.
As far as the country administration has a predefined Gl, this would not a problem (it is when generating a virtual ledger) but for e.g. The Netherlands and USA there is no predefined ledger. User can make extra records if needed, but the always appear on top of a chosen view.

The help of a helperfield in the table e.g. sequence combined with field parent_id would do the trick.

Can someone confirm?
If so I will make a request/bug submission.

Thanks in advance,
Jan

Revision history for this message
Jan Verlaan (jan-verlaan) said :
#3

OpenERP RC3
Proposal for code change in:
/addons/account/account.py
line 127
    class account_account(osv.osv):
        _order = "parent_left"
        _parent_order = "code"
        _name = "account.account"
to
    class account_account(osv.osv):
        _order = "code" #<<== changed order from "parent_left" to "code"
        _parent_order = "code"
        _name = "account.account"

I have tested this change and it gives the right behavior. All chart of accounts are sorted now based on code instead of parent_left.

Revision history for this message
Jan Verlaan (jan-verlaan) said :
#4

Problem is solved with solution on bug https://bugs.launchpad.net/bugs/315212