Skip to Content
Menu
This question has been flagged
2 Replies
4408 Views

Hello there,

In the chart of accounts and in the accounts list, we want to sort accounts by CODE.

For example, In the parent account 3, we would want to sort accounts like 3.1, 3.2, 3.3, etc.

Actually, the account_account class is defined like this in Odoo 8 :

class account_account(osv.osv):
    _order = "parent_left"
_parent_order = "code"
_name = "account.account"
_description = "Account"
_parent_store = True


How to override this class account_account to sort by CODE in each parent?

Thanks to help


In image (what we actually have) :


Avatar
Discard
Author Best Answer

I have tried many combinationsfor _order and _parent_order of account_account class. Always get the same error. 

For example, If I tried to change _order directly in the original account.py file like this :

class account_account(osv.osv):
     _order = "code asc" ###instead of _order = "parent_left"
     _parent_order = "code"
     _name = "account.account"
     _description = "Account"
     _parent_store = True

For all combinations I have tried, I got this error :

  File "/home/odoo-iv/odoo-8.0-20170119/openerp/addons/account/account.py", line 364, in __compute
    sums[current.id][fn] += sums[child.id][fn]
KeyError: 144

So, I have decided to change 'parent_left' and 'parent_right' field values for accounts in account.account database's table. I did it manually directly in the database.

Now I have this :

 


Thanks for your answers

Avatar
Discard
Best Answer

dear Pascal

 

Try to make order like this 

_order = 'field1 asc, field2 asc'

Field1: the first to field

Field2: the second to field

I hope I helped you...
Avatar
Discard
Related Posts Replies Views Activity
0
Mar 15
2503
0
Dec 16
2135
2
Feb 19
5622
2
Jun 17
5484
3
Dec 15
4413