line/book: kassenbuch öffnen/anzeige optimiert

This commit is contained in:
Frederik Jaeckel 2022-10-11 10:21:11 +02:00
parent a1784abed6
commit e4423be23e
4 changed files with 40 additions and 78 deletions

34
line.py
View file

@ -984,12 +984,6 @@ class LineContext(ModelView):
'Line Context'
__name__ = 'cashbook.line.context'
cashbook = fields.Many2One(string='Cashbook', required=True,
model_name='cashbook.book',
domain=[('btype', '!=', None)],
states={
'readonly': Eval('num_cashbook', 0) < 2,
}, depends=['num_cashbook'])
date_from = fields.Date(string='Start Date', depends=['date_to'],
help='Limits the date range for the displayed entries.',
domain=[
@ -1008,16 +1002,6 @@ class LineContext(ModelView):
help='Show account lines in Checked-state.')
done = fields.Boolean(string='Done',
help='Show account lines in Done-state.')
num_cashbook = fields.Function(fields.Integer(string='Number of Cashbook',
readonly=True, states={'invisible': True}),
'on_change_with_num_cashbook')
@classmethod
def default_cashbook(cls):
""" get default from context
"""
context = Transaction().context
return context.get('cashbook', None)
@classmethod
def default_date_from(cls):
@ -1040,17 +1024,6 @@ class LineContext(ModelView):
context = Transaction().context
return context.get('checked', False)
@classmethod
def default_num_cashbook(cls):
""" get default from context
"""
CashBook = Pool().get('cashbook.book')
with Transaction().set_context({
'_check_access': True,
}):
return CashBook.search_count([('btype', '!=', None)])
@classmethod
def default_done(cls):
""" get default from context
@ -1058,11 +1031,4 @@ class LineContext(ModelView):
context = Transaction().context
return context.get('done', False)
def on_change_with_num_cashbook(self, name=None):
""" get number of accessible cashbooks,
depends on user-permissions
"""
LineContext = Pool().get('cashbook.line.context')
return LineContext.default_num_cashbook()
# end LineContext