bok, line, type, line-open-wizard, context

This commit is contained in:
Frederik Jaeckel 2022-08-05 16:47:43 +02:00
parent a9f3eb12b4
commit ba442b726e
23 changed files with 974 additions and 8 deletions

View file

@ -5,8 +5,18 @@
from trytond.pool import Pool
from .book import Book
from .account_type import AccountType
from .line import Line, LineContext
from .wizard_openline import OpenCashBook, OpenCashBookStart
def register():
Pool.register(
AccountType,
Book,
LineContext,
Line,
OpenCashBookStart,
module='cashbook', type_='model')
Pool.register(
OpenCashBook,
module='cashbook', type_='wizard')

42
account_type.py Normal file
View file

@ -0,0 +1,42 @@
# -*- 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, Unique
class AccountType(ModelSQL, ModelView):
'Account Type'
__name__ = 'cashbook.type'
name = fields.Char(string='Name', required=True, translate=True)
short = fields.Char(string='Abbreviation', required=True, size=3)
@classmethod
def __setup__(cls):
super(AccountType, cls).__setup__()
cls._order.insert(0, ('name', 'ASC'))
t = cls.__table__()
cls._sql_constraints = [
('code_uniq', Unique(t, t.short), 'cashbook.msg_type_short_unique'),
]
def get_rec_name(self, name):
""" short + name
"""
return '%(short)s - %(name)s' % {
'short': self.short or '-',
'name': self.name or '-',
}
@classmethod
def search_rec_name(cls, name, clause):
""" search in tracker + ticket-name
"""
return ['OR',
('name',) + tuple(clause[1:]),
('short',) + tuple(clause[1:]),
]
# end AccountType

81
account_type.xml Normal file
View file

@ -0,0 +1,81 @@
<?xml version="1.0"?>
<!-- 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. -->
<tryton>
<data>
<!-- views -->
<record model="ir.ui.view" id="accounttype_view_list">
<field name="model">cashbook.type</field>
<field name="type">tree</field>
<field name="priority" eval="10"/>
<field name="name">accounttype_list</field>
</record>
<record model="ir.ui.view" id="accounttype_view_form">
<field name="model">cashbook.type</field>
<field name="type">form</field>
<field name="priority" eval="20"/>
<field name="name">accounttype_form</field>
</record>
<!-- action view-->
<record model="ir.action.act_window" id="act_accounttype_view">
<field name="name">Account Type</field>
<field name="res_model">cashbook.type</field>
</record>
<record model="ir.action.act_window.view" id="act_accounttype_view-1">
<field name="sequence" eval="10"/>
<field name="view" ref="accounttype_view_list"/>
<field name="act_window" ref="act_accounttype_view"/>
</record>
<record model="ir.action.act_window.view" id="act_accounttype_view-2">
<field name="sequence" eval="20"/>
<field name="view" ref="accounttype_view_form"/>
<field name="act_window" ref="act_accounttype_view"/>
</record>
<!-- permission -->
<!-- anon: deny all -->
<record model="ir.model.access" id="access_type-anon">
<field name="model" search="[('model', '=', 'cashbook.type')]"/>
<field name="perm_read" eval="False"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<!-- admin: read/write -->
<record model="ir.model.access" id="access_type-group_admin">
<field name="model" search="[('model', '=', 'cashbook.type')]"/>
<field name="group" ref="res.group_admin"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<!-- cashbook: read -->
<record model="ir.model.access" id="access_type-group_cashbook">
<field name="model" search="[('model', '=', 'cashbook.type')]"/>
<field name="group" ref="group_cashbook"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<!-- defaults -->
<record model="cashbook.type" id="atype_cash">
<field name="short">CAS</field>
<field name="name">Cash</field>
</record>
<record model="cashbook.type" id="atype_giro">
<field name="short">GIR</field>
<field name="name">Giro</field>
</record>
<record model="cashbook.type" id="atype_fixtermdep">
<field name="short">FTD</field>
<field name="name">Fixed-term deposit</field>
</record>
</data>
</tryton>

View file

@ -11,6 +11,10 @@ class Book(ModelSQL, ModelView):
__name__ = 'cashbook.book'
name = fields.Char(string='Name', required=True)
btype = fields.Many2One(string='Account Type', required=True,
model_name='cashbook.type', ondelete='RESTRICT')
lines = fields.One2Many(string='Lines', field='account',
model_name='cashbook.line')
@classmethod
def __setup__(cls):

View file

@ -8,6 +8,12 @@ full copyright notices and license terms. -->
<record model="res.group" id="group_cashbook">
<field name="name">Cashbook</field>
</record>
<record model="res.group" id="group_cashbook_checkline">
<field name="name">Cashbook - WF - Check</field>
</record>
<record model="res.group" id="group_cashbook_doneline">
<field name="name">Cashbook - WF - Done</field>
</record>
</data>
</tryton>

179
line.py Normal file
View file

@ -0,0 +1,179 @@
# -*- 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, Workflow, fields
from trytond.pool import Pool
from trytond.pyson import Eval, If
from trytond.transaction import Transaction
sel_linetype = [
('edit', 'Edit'),
('check', 'Checked'),
('done', 'Done'),
]
STATES = {
'readonly': Eval('state', '') != 'edit',
}
DEPENDS=['state']
class LineContext(ModelView):
'Line Context'
__name__ = 'cashbook.line.context'
account = fields.Many2One(string='Account', required=True,
model_name='cashbook.book',
states={
'readonly': Eval('num_account', 0) < 2,
}, depends=['num_account'])
date_from = fields.Date(string='Start Date', depends=['date_to'],
domain=[
If(Eval('date_to') & Eval('date_from'),
('date_from', '<=', Eval('date_to')),
()),
])
date_to = fields.Date(string='End Date', depends=['date_from'],
domain=[
If(Eval('date_to') & Eval('date_from'),
('date_from', '<=', Eval('date_to')),
()),
])
checked = fields.Boolean(string='Checked',
help='Show account lines in Checked-state.')
done = fields.Boolean(string='Done',
help='Show account lines in Done-state.')
num_account = fields.Function(fields.Integer(string='Number of Accounts',
readonly=True, states={'invisible': True}),
'on_change_with_num_account')
@classmethod
def default_account(cls):
""" get default from context
"""
context = Transaction().context
return context.get('account', None)
@classmethod
def default_date_from(cls):
""" get default from context
"""
context = Transaction().context
return context.get('date_from', None)
@classmethod
def default_date_to(cls):
""" get default from context
"""
context = Transaction().context
return context.get('date_to', None)
@classmethod
def default_checked(cls):
""" get default from context
"""
context = Transaction().context
return context.get('checked', False)
@classmethod
def default_done(cls):
""" get default from context
"""
context = Transaction().context
return context.get('done', False)
def on_change_with_num_account(self, name=None):
""" get number of accessible accounts,
depends on user-permissions
"""
CashBook = Pool().get('cashbook.book')
return CashBook.search_count([])
# end LineContext
class Line(Workflow, ModelSQL, ModelView):
'Account Line'
__name__ = 'cashbook.line'
account = fields.Many2One(string='Account', required=True, select=True,
model_name='cashbook.book', ondelete='CASCADE', readonly=True)
date = fields.Date(string='Date', required=True, select=True,
states=STATES, depends=DEPENDS)
description = fields.Char(string='Description',
states=STATES, depends=DEPENDS)
state = fields.Selection(string='State', required=True, readonly=True,
select=True, selection=sel_linetype)
@classmethod
def __setup__(cls):
super(Line, cls).__setup__()
cls._order.insert(0, ('date', 'ASC'))
cls._transitions |= set((
('edit', 'check'),
('check', 'done'),
('check', 'edit'),
))
cls._buttons.update({
'wfedit': {
'invisible': Eval('state', '') != 'check',
'depends': ['state'],
},
'wfcheck': {
'invisible': Eval('state') != 'edit',
'depends': ['state'],
},
'wfdone': {
'invisible': Eval('state') != 'check',
'depends': ['state'],
},
})
@classmethod
@ModelView.button
@Workflow.transition('edit')
def wfedit(cls, lines):
""" edit line
"""
pass
@classmethod
@ModelView.button
@Workflow.transition('check')
def wfcheck(cls, lines):
""" line is checked
"""
pass
@classmethod
@ModelView.button
@Workflow.transition('done')
def wfdone(cls, lines):
""" line is done
"""
pass
@classmethod
def default_state(cls):
""" default: edit
"""
return 'edit'
@classmethod
def default_date(cls):
""" default: today
"""
IrDate = Pool().get('ir.date')
return IrDate.today()
@classmethod
def default_account(cls):
""" get default from context
"""
context = Transaction().context
return context.get('account', None)
# end Line

147
line.xml Normal file
View file

@ -0,0 +1,147 @@
<?xml version="1.0"?>
<!-- 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. -->
<tryton>
<data>
<record model="ir.ui.view" id="cashbook_line_context_form_form">
<field name="model">cashbook.line.context</field>
<field name="type">form</field>
<field name="name">cashbook_line_context_form</field>
</record>
<!-- views -->
<record model="ir.ui.view" id="line_view_list">
<field name="model">cashbook.line</field>
<field name="type">tree</field>
<field name="priority" eval="10"/>
<field name="name">line_list</field>
</record>
<record model="ir.ui.view" id="line_view_form">
<field name="model">cashbook.line</field>
<field name="type">form</field>
<field name="priority" eval="20"/>
<field name="name">line_form</field>
</record>
<!-- action view -->
<record model="ir.action.act_window" id="act_line_view">
<field name="name">Account Line</field>
<field name="res_model">cashbook.line</field>
<field name="context_model">cashbook.line.context</field>
<field name="context_domain"
eval="[
('account', '=', Eval('account', -1)),
If(Bool(Eval('date_from')), ('date', '&gt;=', Eval('date_from')), ()),
If(Bool(Eval('date_to')), ('date', '&lt;=', Eval('date_to')), ()),
['OR',
('state', '=', 'edit'),
If(Bool(Eval('done')), ('state', '=', 'done'), ('state', '=', 'edit')),
If(Bool(Eval('checked')), ('state', '=', 'check'), ('state', '=', 'edit')),
],
]"
pyson="1"/>
</record>
<record model="ir.action.act_window.view" id="act_line_view-1">
<field name="sequence" eval="10"/>
<field name="view" ref="line_view_list"/>
<field name="act_window" ref="act_line_view"/>
</record>
<record model="ir.action.act_window.view" id="act_line_view-2">
<field name="sequence" eval="20"/>
<field name="view" ref="line_view_form"/>
<field name="act_window" ref="act_line_view"/>
</record>
<!-- permission -->
<!-- anon: deny all -->
<record model="ir.model.access" id="access_line-anon">
<field name="model" search="[('model', '=', 'cashbook.line')]"/>
<field name="perm_read" eval="False"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<!-- admin: read/write -->
<record model="ir.model.access" id="access_line-group_admin">
<field name="model" search="[('model', '=', 'cashbook.line')]"/>
<field name="group" ref="res.group_admin"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<!-- cashbook: read -->
<record model="ir.model.access" id="access_line-group_cashbook">
<field name="model" search="[('model', '=', 'cashbook.line')]"/>
<field name="group" ref="group_cashbook"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<!-- button - edit -->
<record model="ir.model.button" id="line_wfedit_button">
<field name="name">wfedit</field>
<field name="string">Edit</field>
<field name="model" search="[('model', '=', 'cashbook.line')]"/>
</record>
<record model="ir.model.button-res.group"
id="line_wfedit_button-group_admin">
<field name="button" ref="line_wfedit_button"/>
<field name="group" ref="res.group_admin"/>
</record>
<record model="ir.model.button-res.group"
id="line_wfedit_button-group_cashbook_checkline">
<field name="button" ref="line_wfedit_button"/>
<field name="group" ref="group_cashbook_checkline"/>
</record>
<record model="ir.model.button-res.group"
id="line_wfedit_button-group_cashbook_doneline">
<field name="button" ref="line_wfedit_button"/>
<field name="group" ref="group_cashbook_doneline"/>
</record>
<!-- button - check -->
<record model="ir.model.button" id="line_wfcheck_button">
<field name="name">wfcheck</field>
<field name="string">Check</field>
<field name="model" search="[('model', '=', 'cashbook.line')]"/>
</record>
<record model="ir.model.button-res.group"
id="line_wfcheck_button-group_admin">
<field name="button" ref="line_wfcheck_button"/>
<field name="group" ref="res.group_admin"/>
</record>
<record model="ir.model.button-res.group"
id="line_wfcheck_button-group_cashbook_checkline">
<field name="button" ref="line_wfcheck_button"/>
<field name="group" ref="group_cashbook_checkline"/>
</record>
<record model="ir.model.button-res.group"
id="line_wfcheck_button-group_cashbook_doneline">
<field name="button" ref="line_wfcheck_button"/>
<field name="group" ref="group_cashbook_doneline"/>
</record>
<!-- button - done -->
<record model="ir.model.button" id="line_wfdone_button">
<field name="name">wfdone</field>
<field name="string">Done</field>
<field name="model" search="[('model', '=', 'cashbook.line')]"/>
</record>
<record model="ir.model.button-res.group"
id="line_wfdone_button-group_admin">
<field name="button" ref="line_wfdone_button"/>
<field name="group" ref="res.group_admin"/>
</record>
<record model="ir.model.button-res.group"
id="line_wfdone_button-group_cashbook_doneline">
<field name="button" ref="line_wfdone_button"/>
<field name="group" ref="group_cashbook_doneline"/>
</record>
</data>
</tryton>

View file

@ -3,6 +3,18 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
##############
# ir.message #
##############
msgctxt "model:ir.message,text:msg_type_short_unique"
msgid "The Abbreviation must be unique."
msgstr "Das Kürzel muß eindeutig sein."
msgctxt "model:ir.message,text:msg_name_cashbook"
msgid "Cashbook"
msgstr "Kassenbuch"
#############
# res.group #
#############
@ -10,6 +22,14 @@ msgctxt "model:res.group,name:group_cashbook"
msgid "Cashbook"
msgstr "Kassenbuch"
msgctxt "model:res.group,name:group_cashbook_checkline"
msgid "Cashbook - WF - Check"
msgstr "Kassenbuch - WF - Prüfen"
msgctxt "model:res.group,name:group_cashbook_doneline"
msgid "Cashbook - WF - Done"
msgstr "Kassenbuch - WF - Fertig"
##############
# ir.ui.menu #
@ -18,10 +38,22 @@ msgctxt "model:ir.ui.menu,name:menu_cashbook"
msgid "Cashbook"
msgstr "Kassenbuch"
msgctxt "model:ir.ui.menu,name:menu_config"
msgid "Configuration"
msgstr "Konfiguration"
msgctxt "model:ir.ui.menu,name:menu_accounttype"
msgid "Account Type"
msgstr "Kontotyp"
msgctxt "model:ir.ui.menu,name:menu_account"
msgid "Account"
msgstr "Konto"
msgctxt "model:ir.ui.menu,name:menu_open_accountlines"
msgid "Open Cashbook"
msgstr "Kassenbuch öffnen"
#############
# ir.action #
@ -30,6 +62,38 @@ msgctxt "model:ir.action,name:act_book_view"
msgid "Account"
msgstr "Konto"
msgctxt "model:ir.action,name:act_accounttype_view"
msgid "Account Type"
msgstr "Kontotyp"
msgctxt "model:ir.action,name:act_line_view"
msgid "Account Line"
msgstr "Kontozeile"
msgctxt "model:ir.action,name:act_line_view"
msgid "Account Line"
msgstr "Kontozeile"
msgctxt "model:ir.action,name:act_open_chart"
msgid "Open Cashbook"
msgstr "Kassenbuch öffnen"
###################
# ir.model.button #
###################
msgctxt "model:ir.model.button,string:line_wfedit_button"
msgid "Edit"
msgstr "Bearbeiten"
msgctxt "model:ir.model.button,string:line_wfcheck_button"
msgid "Check"
msgstr "Prüfen"
msgctxt "model:ir.model.button,string:line_wfdone_button"
msgid "Done"
msgstr "Fertig"
#################
# cashbook.book #
@ -41,3 +105,172 @@ msgstr "Konto"
msgctxt "field:cashbook.book,name:"
msgid "Name"
msgstr "Name"
msgctxt "field:cashbook.book,btype:"
msgid "Account Type"
msgstr "Kontotyp"
#################
# cashbook.line #
#################
msgctxt "model:cashbook.line,name:"
msgid "Account Line"
msgstr "Kontozeile"
msgctxt "field:cashbook.line,account:"
msgid "Account"
msgstr "Konto"
msgctxt "field:cashbook.line,date:"
msgid "Date"
msgstr "Datum"
msgctxt "field:cashbook.line,description:"
msgid "Description"
msgstr "Beschreibung"
msgctxt "field:cashbook.line,state:"
msgid "State"
msgstr "Status"
msgctxt "selection:cashbook.line,state:"
msgid "Edit"
msgstr "Bearbeiten"
msgctxt "selection:cashbook.line,state:"
msgid "Checked"
msgstr "Geprüft"
msgctxt "selection:cashbook.line,state:"
msgid "Done"
msgstr "Fertig"
#################
# cashbook.type #
#################
msgctxt "model:cashbook.type,name:"
msgid "Account Type"
msgstr "Kontotyp"
msgctxt "field:cashbook.type,name:"
msgid "Name"
msgstr "Name"
msgctxt "field:cashbook.type,short:"
msgid "Abbreviation"
msgstr "Kürzel"
msgctxt "model:cashbook.type,name:atype_cash"
msgid "Cash"
msgstr "Bar"
msgctxt "model:cashbook.type,short:atype_cash"
msgid "CAS"
msgstr "CAS"
msgctxt "model:cashbook.type,name:atype_giro"
msgid "Giro"
msgstr "Giro"
msgctxt "model:cashbook.type,short:atype_giro"
msgid "GIR"
msgstr "GIR"
msgctxt "model:cashbook.type,name:atype_fixtermdep"
msgid "Fixed-term deposit"
msgstr "Festgeld"
msgctxt "model:cashbook.type,short:atype_fixtermdep"
msgid "FIX"
msgstr "FIX"
####################################
# cashbook.open_accountlines.start #
####################################
msgctxt "model:cashbook.open_accountlines.start,name:"
msgid "Open Cashbook"
msgstr "Kassenbuch öffnen"
msgctxt "field:cashbook.open_accountlines.start,account:"
msgid "Account"
msgstr "Konto"
msgctxt "field:cashbook.open_accountlines.start,checked:"
msgid "Checked"
msgstr "Geprüft"
msgctxt "help:cashbook.open_accountlines.start,checked:"
msgid "Show account lines in Checked-state."
msgstr "Zeigt Kontozeilen im 'Geprüft'-Status"
msgctxt "field:cashbook.open_accountlines.start,done:"
msgid "Done"
msgstr "Fertig"
msgctxt "help:cashbook.open_accountlines.start,done:"
msgid "Show account lines in Done-state."
msgstr "Zeigt Kontozeilen im 'Fertig'-Status"
msgctxt "field:cashbook.open_accountlines.start,date_from:"
msgid "Start Date"
msgstr "Beginndatum"
msgctxt "field:cashbook.open_accountlines.start,date_to:"
msgid "End Date"
msgstr "Endedatum"
##############################
# cashbook.open_accountlines #
##############################
msgctxt "model:cashbook.open_accountlines,name:"
msgid "Open Cashbook"
msgstr "Kassenbuch öffnen"
msgctxt "wizard_button:cashbook.open_accountlines,start,end:"
msgid "Cancel"
msgstr "Abbruch"
msgctxt "wizard_button:cashbook.open_accountlines,start,open_:"
msgid "Open"
msgstr "Öffnen"
#########################
# cashbook.line.context #
#########################
msgctxt "model:cashbook.line.context,name:"
msgid "Line Context"
msgstr "Zeilenkontext"
msgctxt "field:cashbook.line.context,account:"
msgid "Account"
msgstr "Konto"
msgctxt "field:cashbook.line.context,checked:"
msgid "Checked"
msgstr "Geprüft"
msgctxt "help:cashbook.line.context,checked:"
msgid "Show account lines in Checked-state."
msgstr "Zeigt Kontozeilen im 'Geprüft'-Status"
msgctxt "field:cashbook.line.context,done:"
msgid "Done"
msgstr "Fertig"
msgctxt "help:cashbook.line.context,done:"
msgid "Show account lines in Done-state."
msgstr "Zeigt Kontozeilen im 'Fertig'-Status"
msgctxt "field:cashbook.line.context,date_from:"
msgid "Start Date"
msgstr "Beginndatum"
msgctxt "field:cashbook.line.context,date_to:"
msgid "End Date"
msgstr "Endedatum"

View file

@ -6,8 +6,8 @@ full copyright notices and license terms. -->
<data>
<!-- menu: /Cashbook -->
<menuitem id="menu_cashbook" name="Cashbook" icon="mds-notebook" />
<menuitem id="menu_cashbook" name="Cashbook"
icon="mds-notebook" />
<record model="ir.ui.menu-res.group" id="menu_cashbook-group_admin">
<field name="menu" ref="menu_cashbook"/>
<field name="group" ref="res.group_admin"/>
@ -17,18 +17,37 @@ full copyright notices and license terms. -->
<field name="group" ref="group_cashbook"/>
</record>
<!-- menu: /Cashbook/Account -->
<menuitem id="menu_account" action="act_book_view" icon="tryton-list"
parent="menu_cashbook" sequence="10"/>
<!-- menu: /Cashbook/Configuration -->
<menuitem id="menu_config" name="Configuration"
icon="tryton-list"
parent="menu_cashbook" sequence="10"/>
<record model="ir.ui.menu-res.group" id="menu_config-group_admin">
<field name="menu" ref="menu_config"/>
<field name="group" ref="res.group_admin"/>
</record>
<!-- menu: /Cashbook/Configuration/Account -->
<menuitem id="menu_account" action="act_book_view"
icon="tryton-list"
parent="menu_config" sequence="10"/>
<record model="ir.ui.menu-res.group" id="menu_account-group_admin">
<field name="menu" ref="menu_account"/>
<field name="group" ref="res.group_admin"/>
</record>
<record model="ir.ui.menu-res.group" id="menu_account-group_cashbook">
<field name="menu" ref="menu_account"/>
<field name="group" ref="group_cashbook"/>
<!-- menu: /Cashbook/Configuration/Account types -->
<menuitem id="menu_accounttype" action="act_accounttype_view"
icon="tryton-list"
parent="menu_config" sequence="20"/>
<record model="ir.ui.menu-res.group" id="menu_accounttype-group_admin">
<field name="menu" ref="menu_accounttype"/>
<field name="group" ref="res.group_admin"/>
</record>
<!-- menu: /Cashbook/Open Cashbook -->
<menuitem id="menu_open_accountlines" action="act_open_accountlines"
icon="tryton-tree"
parent="menu_cashbook" sequence="20"/>
</data>
</tryton>

View file

@ -5,6 +5,12 @@ full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.message" id="msg_type_short_unique">
<field name="text">The Abbreviation must be unique.</field>
</record>
<record model="ir.message" id="msg_name_cashbook">
<field name="text">Cashbook</field>
</record>
</data>
</tryton>

24
tests/__init__.py Normal file
View file

@ -0,0 +1,24 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import trytond.tests.test_tryton
import unittest
from trytond.modules.cashbook.tests.test_accounttype import AccounttypeTestCase
__all__ = ['suite']
class CashbookTestCase(\
AccounttypeTestCase,
):
'Test cashbook module'
module = 'cashbook'
# end CashbookTestCase
def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(CashbookTestCase))
return suite

37
tests/test_accounttype.py Normal file
View file

@ -0,0 +1,37 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import os, requests
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
from trytond.pool import Pool
from trytond.transaction import Transaction
from trytond.exceptions import UserError
class AccounttypeTestCase(ModuleTestCase):
'Test account type module'
module = 'cashbook'
@with_transaction()
def test_accounttype_create(self):
""" create account type
"""
AccType = Pool().get('cashbook.type')
at, = AccType.create([{
'name': 'Test 1',
'short': 'T1',
}])
self.assertEqual(at.name, 'Test 1')
self.assertEqual(at.short, 'T1')
# check unique of short
self.assertRaisesRegex(UserError,
'The Abbreviation must be unique.',
AccType.create,
[{
'name': 'Test 2',
'short': 'T1',
}])
# end AccounttypeTestCase

View file

@ -5,5 +5,9 @@ depends:
xml:
icon.xml
group.xml
message.xml
account_type.xml
book.xml
line.xml
wizard_openline.xml
menu.xml

10
view/accounttype_form.xml Normal file
View file

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!-- 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>
<label name="short"/>
<field name="short"/>
<label name="name"/>
<field name="name"/>
</form>

View file

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!-- 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. -->
<tree>
<field name="short"/>
<field name="name"/>
</tree>

View file

@ -5,4 +5,6 @@ full copyright notices and license terms. -->
<form>
<label name="name"/>
<field name="name"/>
<label name="btype"/>
<field name="btype"/>
</form>

View file

@ -4,4 +4,5 @@ The COPYRIGHT file at the top level of this repository contains the
full copyright notices and license terms. -->
<tree>
<field name="name"/>
<field name="btype"/>
</tree>

View file

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<!-- 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="10">
<label name="account"/>
<field name="account" widget="selection"/>
<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"/>
</form>

20
view/line_form.xml Normal file
View file

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!-- 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>
<label name="account"/>
<field name="account" colspan="3"/>
<label name="date"/>
<field name="date"/>
<label name="state"/>
<field name="state"/>
<label name="description"/>
<field name="description"/>
<button name="wfedit"/>
<button name="wfcheck"/>
</form>

12
view/line_list.xml Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!-- 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. -->
<tree>
<field name="account"/>
<field name="date"/>
<field name="description"/>
<field name="state"/>
<button name="wfedit"/>
<button name="wfcheck"/>
</tree>

View file

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<!-- 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>
<label name="account"/>
<field name="account" colspan="3" widget="selection"/>
<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"/>
</form>

62
wizard_openline.py Normal file
View file

@ -0,0 +1,62 @@
# -*- 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

21
wizard_openline.xml Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!-- 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. -->
<tryton>
<data>
<record model="ir.ui.view" id="open_accountlines_view_form">
<field name="model">cashbook.open_accountlines.start</field>
<field name="type">form</field>
<field name="name">wizard_openline_form</field>
</record>
<!-- open line view by wizard to select account -->
<record model="ir.action.wizard" id="act_open_accountlines">
<field name="name">Open Cashbook</field>
<field name="wiz_name">cashbook.open_accountlines</field>
</record>
</data>
</tryton>