line/book: kassenbuch öffnen/anzeige optimiert

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

View file

@ -12,6 +12,32 @@ from trytond.exceptions import UserError
from trytond.transaction import Transaction
class OLineMixin:
""" mixin to extend action-data
"""
def add_action_data(self, book):
""" add book and cfg
"""
Configuration = Pool().get('cashbook.configuration')
cfg1 = Configuration.get_singleton()
action = {
'pyson_context': PYSONEncoder().encode({
'cashbook': getattr(book, 'id', None),
'date_from': getattr(cfg1, 'date_from', None),
'date_to': getattr(cfg1, 'date_to', None),
'checked': getattr(cfg1, 'checked', None),
'done': getattr(cfg1, 'done', None),
}),
'name' : '%(name)s: %(cashbook)s' % {
'name': gettext('cashbook.msg_name_cashbook'),
'cashbook': getattr(book, 'rec_name', '-/-'),
},
}
return action
# OLineMixin
class OpenCashBookStart(ModelView):
'Open Cashbook'
__name__ = 'cashbook.open_lines.start'
@ -34,7 +60,7 @@ class OpenCashBookStart(ModelView):
# end OpenCashBookStart
class OpenCashBook(Wizard):
class OpenCashBook(OLineMixin, Wizard):
'Open Cashbook'
__name__ = 'cashbook.open_lines'
@ -95,29 +121,13 @@ class OpenCashBook(Wizard):
if len(books) > 0:
book = books[0]
date_from = getattr(self.askuser, 'date_from', None)
date_to = getattr(self.askuser, 'date_to', None)
checked = getattr(self.askuser, 'checked', True)
done = getattr(self.askuser, 'done', False)
# save settings
cfg1.date_from = date_from
cfg1.date_to = date_to
cfg1.checked = checked
cfg1.done = done
cfg1.date_from = getattr(self.askuser, 'date_from', None)
cfg1.date_to = getattr(self.askuser, 'date_to', None)
cfg1.checked = getattr(self.askuser, 'checked', True)
cfg1.done = getattr(self.askuser, 'done', False)
cfg1.save()
action['pyson_context'] = PYSONEncoder().encode({
'cashbook': getattr(book, 'id', None),
'date_from': date_from,
'date_to': date_to,
'checked': checked,
'done': done,
})
action['name'] = '%(name)s: %(cashbook)s' % {
'name': gettext('cashbook.msg_name_cashbook'),
'cashbook': getattr(book, 'rec_name', '-/-'),
}
action.update(self.add_action_data(book))
return action, {}
def transition_open_(self):
@ -126,7 +136,7 @@ class OpenCashBook(Wizard):
# end OpenCashBook
class OpenCashBookTree(Wizard):
class OpenCashBookTree(OLineMixin, Wizard):
'Open Cashbook2'
__name__ = 'cashbook.open_lines_tree'
@ -160,17 +170,7 @@ class OpenCashBookTree(Wizard):
bookname = book.rec_name,
))
action['pyson_context'] = PYSONEncoder().encode({
'cashbook': getattr(book, 'id', None),
'date_from': cfg1.date_from,
'date_to': cfg1.date_to,
'checked': cfg1.checked,
'done': cfg1.done,
})
action['name'] = '%(name)s: %(cashbook)s' % {
'name': gettext('cashbook.msg_name_cashbook'),
'cashbook': getattr(book, 'rec_name', '-/-'),
}
action.update(self.add_action_data(book))
return action, {}
# end OpenCashBookTree