Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
5342 Vistas

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
Descartar
Autor Mejor respuesta

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
mar 15
3299
0
dic 16
3179
2
feb 19
6384
2
jun 17
6585
3
dic 15
5163