2022-08-05 14:47:43 +00:00
|
|
|
# -*- 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'
|
2022-08-08 12:31:42 +00:00
|
|
|
__name__ = 'cashbook.open_lines.start'
|
2022-08-05 14:47:43 +00:00
|
|
|
|
2022-08-08 12:31:42 +00:00
|
|
|
cashbook = fields.Many2One(string='Cashbook', model_name='cashbook.book',
|
2022-08-05 14:47:43 +00:00
|
|
|
required=True)
|
2022-08-08 12:31:42 +00:00
|
|
|
checked = fields.Boolean(string='Checked', help="Show cashbook lines in Checked-state.")
|
|
|
|
done = fields.Boolean(string='Done', help="Show cashbook lines in Done-state")
|
2022-08-05 14:47:43 +00:00
|
|
|
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'
|
2022-08-08 12:31:42 +00:00
|
|
|
__name__ = 'cashbook.open_lines'
|
2022-08-05 14:47:43 +00:00
|
|
|
|
2022-08-08 12:31:42 +00:00
|
|
|
start = StateView('cashbook.open_lines.start',
|
|
|
|
'cashbook.open_lines_view_form', [
|
2022-08-05 14:47:43 +00:00
|
|
|
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({
|
2022-08-08 12:31:42 +00:00
|
|
|
'cashbook': self.start.cashbook.id,
|
2022-08-05 14:47:43 +00:00
|
|
|
'date_from': self.start.date_from,
|
|
|
|
'date_to': self.start.date_to,
|
|
|
|
'checked': self.start.checked,
|
|
|
|
'done': self.start.done,
|
|
|
|
})
|
2022-08-08 12:31:42 +00:00
|
|
|
action['name'] = '%(name)s: %(cashbook)s' % {
|
2022-08-05 14:47:43 +00:00
|
|
|
'name': gettext('cashbook.msg_name_cashbook'),
|
2022-08-08 12:31:42 +00:00
|
|
|
'cashbook': self.start.cashbook.rec_name,
|
2022-08-05 14:47:43 +00:00
|
|
|
}
|
|
|
|
return action, {}
|
|
|
|
|
|
|
|
def transition_open_(self):
|
|
|
|
return 'end'
|
|
|
|
|
|
|
|
# end OpenCashBook
|