63 lines
2 KiB
Python
63 lines
2 KiB
Python
![]() |
# -*- coding: utf-8 -*-
|
||
|
# 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.
|
||
|
|
||
|
from trytond.model import ModelView, ModelSQL, fields
|
||
|
from trytond.pyson import PYSONEncoder
|
||
|
from trytond.wizard import Wizard, StateView, StateAction, Button
|
||
|
from trytond.i18n import gettext
|
||
|
|
||
|
|
||
|
class OpenCashBookStart(ModelView):
|
||
|
'Open Cashbook'
|
||
|
__name__ = 'cashbook.open_accountlines.start'
|
||
|
|
||
|
account = fields.Many2One(string='Account', model_name='cashbook.book',
|
||
|
required=True)
|
||
|
checked = fields.Boolean(string='Checked', help="Show account lines in Checked-state.")
|
||
|
done = fields.Boolean(string='Done', help="Show account lines in Done-state")
|
||
|
date_from = fields.Date(string='Start Date')
|
||
|
date_to = fields.Date(string='End Date')
|
||
|
|
||
|
@classmethod
|
||
|
def default_checked(cls):
|
||
|
return True
|
||
|
|
||
|
@classmethod
|
||
|
def default_done(cls):
|
||
|
return False
|
||
|
|
||
|
# end OpenCashBookStart
|
||
|
|
||
|
|
||
|
class OpenCashBook(Wizard):
|
||
|
'Open Cashbook'
|
||
|
__name__ = 'cashbook.open_accountlines'
|
||
|
|
||
|
start = StateView('cashbook.open_accountlines.start',
|
||
|
'cashbook.open_accountlines_view_form', [
|
||
|
Button('Cancel', 'end', 'tryton-cancel'),
|
||
|
Button('Open', 'open_', 'tryton-ok', default=True),
|
||
|
])
|
||
|
open_ = StateAction('cashbook.act_line_view')
|
||
|
|
||
|
def do_open_(self, action):
|
||
|
action['pyson_context'] = PYSONEncoder().encode({
|
||
|
'account': self.start.account.id,
|
||
|
'date_from': self.start.date_from,
|
||
|
'date_to': self.start.date_to,
|
||
|
'checked': self.start.checked,
|
||
|
'done': self.start.done,
|
||
|
})
|
||
|
action['name'] = '%(name)s: %(account)s' % {
|
||
|
'name': gettext('cashbook.msg_name_cashbook'),
|
||
|
'account': self.start.account.rec_name,
|
||
|
}
|
||
|
return action, {}
|
||
|
|
||
|
def transition_open_(self):
|
||
|
return 'end'
|
||
|
|
||
|
# end OpenCashBook
|