account in module 'cashbook_account' verschoben
This commit is contained in:
parent
149baef174
commit
7a07da852d
18 changed files with 41 additions and 220 deletions
56
category.py
56
category.py
|
@ -34,11 +34,6 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView):
|
|||
readonly=True, states={'invisible': True}),
|
||||
'on_change_with_parent_cattype')
|
||||
|
||||
account = fields.Many2One(string='Account', select=True,
|
||||
model_name='account.account', ondelete='RESTRICT')
|
||||
account_code = fields.Function(fields.Char(string='Account', readonly=True),
|
||||
'on_change_with_account_code', searcher='search_account_code')
|
||||
|
||||
company = fields.Many2One(string='Company', model_name='company.company',
|
||||
required=True, ondelete="RESTRICT")
|
||||
sequence = fields.Integer(string='Sequence', select=True)
|
||||
|
@ -57,7 +52,6 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView):
|
|||
t = cls.__table__()
|
||||
cls._sql_constraints.extend([
|
||||
('name_uniq', Unique(t, t.name, t.company, t.parent), 'cashbook.msg_category_name_unique'),
|
||||
('account_uniq', Unique(t, t.account, t.company), 'cashbook.msg_category_account_unique'),
|
||||
])
|
||||
|
||||
@classmethod
|
||||
|
@ -76,37 +70,6 @@ class Category(tree(separator='/'), sequence_ordered(), 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
|
||||
"""
|
||||
return self.get_long_recname(
|
||||
super(Category, self).get_rec_name(name)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def search_rec_name(cls, name, clause):
|
||||
""" search in account + name
|
||||
"""
|
||||
return ['OR',
|
||||
super(Category, cls).search_rec_name(name, clause),
|
||||
('account.rec_name',) + tuple(clause[1:]),
|
||||
('account.code',) + tuple(clause[1:]),
|
||||
]
|
||||
|
||||
@fields.depends('parent', '_parent_parent.cattype')
|
||||
def on_change_with_parent_cattype(self, name=None):
|
||||
""" get type of parent category or None
|
||||
|
@ -114,19 +77,6 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView):
|
|||
if self.parent:
|
||||
return self.parent.cattype
|
||||
|
||||
@fields.depends('account')
|
||||
def on_change_with_account_code(self, name=None):
|
||||
""" get code of account
|
||||
"""
|
||||
if self.account:
|
||||
return self.account.code
|
||||
|
||||
@classmethod
|
||||
def search_account_code(cls, names, clause):
|
||||
""" search in code
|
||||
"""
|
||||
return [('account.code',) + tuple(clause[1:])]
|
||||
|
||||
@classmethod
|
||||
def check_category_hierarchy(cls, categories):
|
||||
""" check if current category-type is equal to parent
|
||||
|
@ -153,6 +103,8 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView):
|
|||
""" parent.cattape == cattype,
|
||||
update sub-categories
|
||||
"""
|
||||
Category2 = Pool().get('cashbook.category')
|
||||
|
||||
actions = iter(args)
|
||||
to_check = []
|
||||
to_write = []
|
||||
|
@ -162,8 +114,8 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView):
|
|||
|
||||
if 'cattype' in values.keys():
|
||||
# update sub-categories
|
||||
cats = Category.search([
|
||||
('parent', 'child_of', [x.id for x in categories])
|
||||
cats = Category2.search([
|
||||
('parent', 'child_of', [x.id for x in categories]),
|
||||
])
|
||||
if len(cats) > 0:
|
||||
to_write.extend([
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue