kategorie, verknüpfung zu kassenbuch, forms
This commit is contained in:
parent
5bb6421692
commit
c69b9c86d8
16 changed files with 561 additions and 0 deletions
50
category.py
Normal file
50
category.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.model import ModelView, ModelSQL, fields, tree
|
||||
from trytond.modules.cashbook.model import order_name_hierarchical
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class Category(tree(separator=' / '), ModelSQL, ModelView):
|
||||
"Cashbook Category"
|
||||
__name__ = "cashbook.bookcategory"
|
||||
|
||||
company = fields.Many2One(string='Company', model_name='company.company',
|
||||
required=True, ondelete="RESTRICT")
|
||||
name = fields.Char(string='Name', required=True, translate=True)
|
||||
|
||||
parent = fields.Many2One(string='Parent', select=True,
|
||||
model_name='cashbook.bookcategory', ondelete='CASCADE',
|
||||
left='left', right='right')
|
||||
childs = fields.One2Many(string='Children', field='parent',
|
||||
model_name='cashbook.bookcategory')
|
||||
left = fields.Integer(string='Left', required=True, select=True)
|
||||
right = fields.Integer(string='Right', required=True, select=True)
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Category, cls).__setup__()
|
||||
cls._order.insert(0, ('rec_name', 'ASC'))
|
||||
|
||||
@staticmethod
|
||||
def default_left():
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def default_right():
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
return Transaction().context.get('company') or None
|
||||
|
||||
@staticmethod
|
||||
def order_rec_name(tables):
|
||||
""" order by pos
|
||||
a recursive sorting
|
||||
"""
|
||||
return order_name_hierarchical('cashbook.bookcategory', tables)
|
||||
|
||||
# ende Category
|
Loading…
Add table
Add a link
Reference in a new issue