line/book: kassenbuch öffnen/anzeige optimiert
This commit is contained in:
parent
557a8b47ba
commit
ef32bd79f9
4 changed files with 40 additions and 78 deletions
34
line.py
34
line.py
|
@ -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
|
||||
|
|
4
line.xml
4
line.xml
|
@ -32,7 +32,6 @@ full copyright notices and license terms. -->
|
|||
<field name="context_model">cashbook.line.context</field>
|
||||
<field name="context_domain"
|
||||
eval="[
|
||||
('cashbook', '=', Eval('cashbook', -1)),
|
||||
If(Bool(Eval('date_from')), ('date', '>=', Eval('date_from')), ()),
|
||||
If(Bool(Eval('date_to')), ('date', '<=', Eval('date_to')), ()),
|
||||
['OR',
|
||||
|
@ -42,6 +41,9 @@ full copyright notices and license terms. -->
|
|||
],
|
||||
]"
|
||||
pyson="1"/>
|
||||
<field name="domain"
|
||||
eval="[('cashbook', '=', Eval('cashbook', -1))]"
|
||||
pyson="1"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_line_view-1">
|
||||
<field name="sequence" eval="10"/>
|
||||
|
|
|
@ -2,20 +2,14 @@
|
|||
<!-- This file is part of the cashbook-module from m-ds for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the
|
||||
full copyright notices and license terms. -->
|
||||
<form col="6">
|
||||
<label name="cashbook"/>
|
||||
<field name="cashbook" widget="selection" colspan="3"/>
|
||||
|
||||
<label name="checked"/>
|
||||
<field name="checked"/>
|
||||
|
||||
<form col="8">
|
||||
<label name="date_from"/>
|
||||
<field name="date_from"/>
|
||||
<label name="date_to"/>
|
||||
<field name="date_to"/>
|
||||
<label name="checked"/>
|
||||
<field name="checked"/>
|
||||
<label name="done"/>
|
||||
<field name="done"/>
|
||||
|
||||
<field name="num_cashbook"/>
|
||||
</form>
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue