kategory: sortierung begnnen
This commit is contained in:
parent
937124bcaf
commit
7fd42c0b42
2 changed files with 73 additions and 0 deletions
27
category.py
27
category.py
|
@ -10,6 +10,7 @@ from trytond.pyson import Eval, If, Bool
|
|||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
from sql.operators import Equal
|
||||
from sql import With
|
||||
|
||||
|
||||
sel_categorytype = [
|
||||
|
@ -79,6 +80,32 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView):
|
|||
def default_right():
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def order_rec_name(tables):
|
||||
""" order by pos
|
||||
"""
|
||||
Category2 = Pool().get('cashbook.category')
|
||||
tab_cat = Category2.__table__()
|
||||
table, _ = tables[None]
|
||||
|
||||
categories = With('id', 'name', 'name_path', recursive=True)
|
||||
categories.query = select(tab_cat.id, tab_cat.name, array[])
|
||||
|
||||
# ~ with recursive categories (id, level, name, name_path) as (
|
||||
# ~ select "a"."id", 0, "a"."name", array["a"."name"]
|
||||
# ~ from cashbook_category as "a"
|
||||
# ~ where "a"."parent" is null
|
||||
|
||||
# ~ union all
|
||||
|
||||
# ~ select "b"."id", "c"."level" + 1, "b"."name", array_append("c"."name_path", "b"."name")
|
||||
# ~ from cashbook_category as "b"
|
||||
# ~ inner join categories as "c" on "c"."id" = "b"."parent"
|
||||
# ~ )
|
||||
# ~ select "d"."id", array_to_string("d"."name_path", '/') as "rec_name"
|
||||
# ~ from categories as "d"
|
||||
# ~ order by "rec_name"
|
||||
|
||||
@fields.depends('parent', '_parent_parent.cattype')
|
||||
def on_change_with_parent_cattype(self, name=None):
|
||||
""" get type of parent category or None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue