Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
5326 Widoki

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) :


Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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...
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
mar 15
3294
0
gru 16
3175
2
lut 19
6379
2
cze 17
6578
3
gru 15
5154