book/category: hierarchische sortierung, form optimiert

This commit is contained in:
Frederik Jaeckel 2022-09-22 15:40:23 +02:00
parent 1c22aac197
commit 7999440de7
5 changed files with 76 additions and 62 deletions

10
book.py
View file

@ -13,6 +13,7 @@ from trytond.report import Report
from decimal import Decimal
from sql.aggregate import Sum
from sql.conditionals import Case
from .model import order_name_hierarchical
STATES = {
@ -136,7 +137,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
@classmethod
def __setup__(cls):
super(Book, cls).__setup__()
cls._order.insert(0, ('name', 'ASC'))
cls._order.insert(0, ('rec_name', 'ASC'))
cls._order.insert(0, ('state', 'ASC'))
t = cls.__table__()
cls._sql_constraints.extend([
@ -225,6 +226,13 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
)
return [query]
@staticmethod
def order_rec_name(tables):
""" order by pos
a recursive sorting
"""
return order_name_hierarchical('cashbook.book', tables)
def get_rec_name(self, name):
""" name, balance, state
"""