kategorie: sequence-sortierung, rec_name mit/ohne konto-nr,
config: Felder catnamelong+cataccno neu + tests, line: feld category_view neu für spaltenansicht in kassenbuch + tests,
This commit is contained in:
parent
a23407f515
commit
1a85b8e80e
15 changed files with 414 additions and 104 deletions
30
category.py
30
category.py
|
@ -3,11 +3,12 @@
|
|||
# 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, Unique, tree
|
||||
from trytond.model import ModelView, ModelSQL, fields, Unique, tree, sequence_ordered
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
|
||||
|
||||
class Category(tree(separator='/'), ModelSQL, ModelView):
|
||||
class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView):
|
||||
'Category'
|
||||
__name__ = 'cashbook.category'
|
||||
|
||||
|
@ -20,6 +21,7 @@ class Category(tree(separator='/'), ModelSQL, ModelView):
|
|||
|
||||
company = fields.Many2One(string='Company', model_name='company.company',
|
||||
required=True, ondelete="RESTRICT")
|
||||
sequence = fields.Integer(string='Sequence', select=True)
|
||||
parent = fields.Many2One(string="Parent",
|
||||
model_name='cashbook.category', ondelete='RESTRICT',
|
||||
left='left', right='right')
|
||||
|
@ -50,15 +52,26 @@ class Category(tree(separator='/'), ModelSQL, ModelView):
|
|||
def default_right():
|
||||
return 0
|
||||
|
||||
def get_long_recname(self, recname):
|
||||
""" build rec_name with account-no
|
||||
"""
|
||||
Configuration = Pool().get('cashbook.configuration')
|
||||
|
||||
l1 = [recname]
|
||||
|
||||
if self.account:
|
||||
if self.account.code:
|
||||
cfg1 = Configuration.get_singleton()
|
||||
if getattr(cfg1, 'cataccno', True) == True:
|
||||
l1.append('[%s]' % self.account.code)
|
||||
return ' '.join(l1)
|
||||
|
||||
def get_rec_name(self, name):
|
||||
""" short + name
|
||||
"""
|
||||
l1 = []
|
||||
if self.account:
|
||||
if self.account.code:
|
||||
l1.append(self.account.code)
|
||||
l1.append(super(Category, self).get_rec_name(name))
|
||||
return ' '.join(l1)
|
||||
return self.get_long_recname(
|
||||
super(Category, self).get_rec_name(name)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def search_rec_name(cls, name, clause):
|
||||
|
@ -67,6 +80,7 @@ class Category(tree(separator='/'), ModelSQL, ModelView):
|
|||
return ['OR',
|
||||
super(Category, cls).search_rec_name(name, clause),
|
||||
('account.rec_name',) + tuple(clause[1:]),
|
||||
('account.code',) + tuple(clause[1:]),
|
||||
]
|
||||
|
||||
@fields.depends('account')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue