book: öffnet inhalt per aktionsknopf
This commit is contained in:
parent
3073ce6f8d
commit
8910f26c99
6 changed files with 105 additions and 1 deletions
|
@ -8,6 +8,7 @@ from trytond.pyson import PYSONEncoder
|
|||
from trytond.wizard import Wizard, StateView, StateTransition, StateAction, Button
|
||||
from trytond.i18n import gettext
|
||||
from trytond.pool import Pool
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
|
@ -123,3 +124,53 @@ class OpenCashBook(Wizard):
|
|||
return 'end'
|
||||
|
||||
# end OpenCashBook
|
||||
|
||||
|
||||
class OpenCashBookTree(Wizard):
|
||||
'Open Cashbook2'
|
||||
__name__ = 'cashbook.open_lines_tree'
|
||||
|
||||
start_state = 'open_'
|
||||
open_ = StateAction('cashbook.act_line_view')
|
||||
|
||||
def do_open_(self, action):
|
||||
""" open view from doubleclick
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Configuration = pool.get('cashbook.configuration')
|
||||
|
||||
cfg1 = Configuration.get_singleton()
|
||||
if cfg1 is None:
|
||||
cfg1 = Configuration()
|
||||
cfg1.save()
|
||||
|
||||
book = self.record
|
||||
if book is None:
|
||||
with Transaction().set_context({
|
||||
'_check_access': True,
|
||||
}):
|
||||
books = Book.search([('btype', '!=', None)])
|
||||
if len(books) > 0:
|
||||
book = books[0]
|
||||
else :
|
||||
if book.btype is None:
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_book_no_type_noopen',
|
||||
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', '-/-'),
|
||||
}
|
||||
return action, {}
|
||||
|
||||
# end OpenCashBookTree
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue