Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
5340 Lượt xem

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


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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...
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 15
3296
0
thg 12 16
3177
2
thg 2 19
6382
2
thg 6 17
6585
3
thg 12 15
5160