diff --git a/__init__.py b/__init__.py index a3c966b..cb57d15 100644 --- a/__init__.py +++ b/__init__.py @@ -7,6 +7,7 @@ from trytond.pool import Pool from .book import Book from .types import Type from .line import Line, LineContext +from .splitline import SplitLine from .wizard_openline import OpenCashBook, OpenCashBookStart from .wizard_runreport import RunCbReport, RunCbReportStart from .configuration import Configuration, UserConfiguration @@ -23,6 +24,7 @@ def register(): Book, LineContext, Line, + SplitLine, Reconciliation, OpenCashBookStart, RunCbReportStart, diff --git a/line.py b/line.py index 5b58c44..dbc79cb 100644 --- a/line.py +++ b/line.py @@ -31,6 +31,8 @@ sel_linetype = [ sel_bookingtype = [ ('in', 'Revenue'), ('out', 'Expense'), + ('spin', 'Revenue Splitbooking'), + ('spout', 'Expense Splitbooking'), ('mvin', 'Transfer from'), ('mvout', 'Transfer to'), ] @@ -102,7 +104,7 @@ class Line(Workflow, ModelSQL, ModelView): ondelete='RESTRICT', states={ 'readonly': STATES['readonly'], - 'invisible': ~Eval('bookingtype', '').in_(['in', 'out']), + 'invisible': ~Eval('bookingtype', '').in_(['in', 'out', 'spin', 'spout']), }, depends=DEPENDS+['bookingtype']) payee = fields.Function(fields.Reference(string='Payee', readonly=True, selection=sel_payee), 'on_change_with_payee', searcher='search_payee') @@ -113,11 +115,18 @@ class Line(Workflow, ModelSQL, ModelView): 'invisible': ~Bool(Eval('reference')), }, model_name='cashbook.line', ondelete='CASCADE', help='The current row was created by and is controlled by the reference row.') - references = fields.One2Many(string='References', model_name='cashbook.line', + references = fields.One2Many(string='References', + model_name='cashbook.line', help='The rows are created and managed by the current record.', states={ 'invisible': ~Bool(Eval('references')), }, field='reference', readonly=True) + splitlines = fields.One2Many(string='Split booking lines', + model_name='cashbook.split', + help='The rows are created and managed by the current record.', + states={ + 'invisible': ~Bool(Eval('splitlines')), + }, field='line', readonly=True) reconciliation = fields.Many2One(string='Reconciliation', readonly=True, model_name='cashbook.recon', ondelete='SET NULL', @@ -398,7 +407,7 @@ class Line(Workflow, ModelSQL, ModelView): """ get party or cashbook """ if self.bookingtype: - if self.bookingtype in ['in', 'out']: + if self.bookingtype in ['in', 'out', 'spin', 'spout']: if self.party: return 'party.party,%d' % self.party.id elif self.bookingtype in ['mvin', 'mvout']: @@ -488,8 +497,8 @@ class Line(Workflow, ModelSQL, ModelView): """ clear category if not valid type """ types = { - 'in': ['in', 'mvin'], - 'out': ['out', 'mvout'], + 'in': ['in', 'mvin', 'spin'], + 'out': ['out', 'mvout', 'spout'], } if self.bookingtype: @@ -570,12 +579,12 @@ class Line(Workflow, ModelSQL, ModelView): if type_: if amount is not None: - if type_ in ['in', 'mvin']: + if type_ in ['in', 'mvin', 'spin']: return { 'debit': Decimal('0.0'), 'credit': amount, } - elif type_ in ['out', 'mvout']: + elif type_ in ['out', 'mvout', 'spout']: return { 'debit': amount, 'credit': Decimal('0.0'), diff --git a/locale/de.po b/locale/de.po index 256b514..e2ca1a9 100644 --- a/locale/de.po +++ b/locale/de.po @@ -110,10 +110,18 @@ msgctxt "model:ir.message,text:msg_line_bookingtype_in" msgid "Rev" msgstr "Einn." +msgctxt "model:ir.message,text:msg_line_bookingtype_spin" +msgid "Rev/Sp" +msgstr "Einn./Spl." + msgctxt "model:ir.message,text:msg_line_bookingtype_out" msgid "Exp" msgstr "Ausg." +msgctxt "model:ir.message,text:msg_line_bookingtype_spout" +msgid "Exp/Sp" +msgstr "Ausg./Spl." + msgctxt "model:ir.message,text:msg_line_bookingtype_mvin" msgid "from" msgstr "von" @@ -166,6 +174,10 @@ msgctxt "model:ir.rule.group,name:rg_book_read_nonowner" msgid "Observers and Reviewers: Cashbook read" msgstr "Beobachter und Bearbeiter: Kassenbuch lesen" +msgctxt "model:ir.rule.group,name:rg_split_write_adm" +msgid "Administrators: Splitbooking line read/write" +msgstr "Administratoren: Splitbuchungszeile bearbeiten" + msgctxt "model:ir.rule.group,name:rg_book_write_adm" msgid "Administrators: Cashbook read/write" msgstr "Administratoren: Kassenbuch bearbeiten" @@ -174,10 +186,18 @@ msgctxt "model:ir.rule.group,name:rg_line_write_adm" msgid "Administrators: Cashbook line read/write" msgstr "Administratoren: Kassenbuchzeile bearbeiten" +msgctxt "model:ir.rule.group,name:rg_split_write" +msgid "Owners and reviewers: Splitbooking line write" +msgstr "Eigentümer und Bearbeiter: Splitbuchungszeile bearbeiten" + msgctxt "model:ir.rule.group,name:rg_line_write" msgid "Owners and reviewers: Cashbook line write" msgstr "Eigentümer und Bearbeiter: Kassenbuchzeile bearbeiten" +msgctxt "model:ir.rule.group,name:rg_split_read" +msgid "Observer: Splitbooking line read" +msgstr "Beobachter: Splitbuchungszeile lesen" + msgctxt "model:ir.rule.group,name:rg_line_read" msgid "Observer: Cashbook line read" msgstr "Beobachter: Kassenbuchzeile lesen" @@ -186,6 +206,10 @@ msgctxt "model:ir.rule.group,name:rg_line_read" msgid "User in companies" msgstr "Benutzer im Unternehmen" +msgctxt "model:ir.rule.group,name:rg_split_companies" +msgid "User in companies" +msgstr "Benutzer im Unternehmen" + msgctxt "model:ir.rule.group,name:rg_type_companies" msgid "User in companies" msgstr "Benutzer im Unternehmen" @@ -451,6 +475,86 @@ msgid "The numbering of the lines is done in the step Check. If the check mark i msgstr "Die Nummerierung der Zeilen wird beim Schritt 'Prüfen' erledigt. Bei inaktivem Häkchen passiert dies erst bei 'Fertig'." +################## +# cashbook.split # +################## +msgctxt "model:cashbook.split,name:" +msgid "Split booking line" +msgstr "Splitbuchungszeile" + +msgctxt "field:cashbook.split,line:" +msgid "Line" +msgstr "Zeile" + +msgctxt "field:cashbook.split,description:" +msgid "Description" +msgstr "Beschreibung" + +msgctxt "field:cashbook.split,category:" +msgid "Category" +msgstr "Kategorie" + +msgctxt "field:cashbook.split,amount:" +msgid "Amount" +msgstr "Betrag" + +msgctxt "field:cashbook.split,currency:" +msgid "Currency" +msgstr "Währung" + +msgctxt "field:cashbook.split,currency_digits:" +msgid "Currency Digits" +msgstr "Nachkommastellen Währung" + +msgctxt "field:cashbook.split,bookingtype:" +msgid "Type" +msgstr "Typ" + +msgctxt "selection:cashbook.split,bookingtype:" +msgid "Revenue" +msgstr "Einnahme" + +msgctxt "selection:cashbook.split,bookingtype:" +msgid "Revenue Splitbooking" +msgstr "Einnahme Splitbuchung" + +msgctxt "selection:cashbook.split,bookingtype:" +msgid "Expense" +msgstr "Ausgabe" + +msgctxt "selection:cashbook.split,bookingtype:" +msgid "Expense Splitbooking" +msgstr "Ausgabe Splitbuchung" + +msgctxt "selection:cashbook.split,bookingtype:" +msgid "Transfer from" +msgstr "Umbuchung von" + +msgctxt "selection:cashbook.split,bookingtype:" +msgid "Transfer to" +msgstr "Umbuchung nach" + +msgctxt "field:cashbook.split,state:" +msgid "State" +msgstr "Status" + +msgctxt "selection:cashbook.split,state:" +msgid "Edit" +msgstr "Bearbeiten" + +msgctxt "selection:cashbook.split,state:" +msgid "Checked" +msgstr "Geprüft" + +msgctxt "selection:cashbook.split,state:" +msgid "Done" +msgstr "Fertig" + +msgctxt "field:cashbook.split,state_cashbook:" +msgid "State of Cashbook" +msgstr "Kassenbuchstatus" + + ################# # cashbook.line # ################# @@ -530,10 +634,18 @@ msgctxt "selection:cashbook.line,bookingtype:" msgid "Revenue" msgstr "Einnahme" +msgctxt "selection:cashbook.line,bookingtype:" +msgid "Revenue Splitbooking" +msgstr "Einnahme Splitbuchung" + msgctxt "selection:cashbook.line,bookingtype:" msgid "Expense" msgstr "Ausgabe" +msgctxt "selection:cashbook.line,bookingtype:" +msgid "Expense Splitbooking" +msgstr "Ausgabe Splitbuchung" + msgctxt "selection:cashbook.line,bookingtype:" msgid "Transfer from" msgstr "Umbuchung von" diff --git a/message.xml b/message.xml index 2ca8f44..9cea207 100644 --- a/message.xml +++ b/message.xml @@ -80,6 +80,12 @@ full copyright notices and license terms. --> The predecessor '%(recname_p)s' must be in the 'Done' state before you can check the current reconciliation '%(recname_c)s'. + + Rev/Sp + + + Exp/Sp + Rev diff --git a/splitline.py b/splitline.py new file mode 100644 index 0000000..a6571dc --- /dev/null +++ b/splitline.py @@ -0,0 +1,85 @@ +# -*- 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, Check +from trytond.pool import Pool +from trytond.pyson import Eval, If +from .line import sel_linetype, sel_bookingtype, STATES, DEPENDS +from .book import sel_state_book + + +class SplitLine(ModelSQL, ModelView): + 'Split booking line' + __name__ = 'cashbook.split' + + line = fields.Many2One(string='Line', required=True, + select=True, ondelete='CASCADE', model_name='cashbook.line', + readonly=True) + description = fields.Text(string='Description', + states=STATES, depends=DEPENDS) + category = fields.Many2One(string='Category', + model_name='cashbook.category', ondelete='RESTRICT', + states=STATES, depends=DEPENDS+['bookingtype'], + required=True, + domain=[ + If( + Eval('bookingtype', '').in_(['in', 'mvin']), + ('cattype', '=', 'in'), + ('cattype', '=', 'out'), + )]) + amount = fields.Numeric(string='Amount', digits=(16, Eval('currency_digits', 2)), + required=True, states=STATES, depends=DEPENDS+['currency_digits']) + + currency = fields.Function(fields.Many2One(model_name='currency.currency', + string="Currency"), 'on_change_with_currency') + currency_digits = fields.Function(fields.Integer(string='Currency Digits'), + 'on_change_with_currency_digits') + bookingtype = fields.Function(fields.Selection(string='Type', readonly=True, + selection=sel_bookingtype), 'on_change_with_bookingtype') + state = fields.Function(fields.Selection(string='State', readonly=True, + selection=sel_linetype), 'on_change_with_state') + state_cashbook = fields.Function(fields.Selection(string='State of Cashbook', + readonly=True, states={'invisible': True}, selection=sel_state_book), + 'on_change_with_state_cashbook', searcher='search_state_cashbook') + + @fields.depends('line', '_parent_line.state') + def on_change_with_state(self, name=None): + """ get state + """ + if self.line: + return self.line.state + + @fields.depends('line', '_parent_line.cashbook') + def on_change_with_state_cashbook(self, name=None): + """ get state of cashbook + """ + if self.line: + return self.line.cashbook.state + + @fields.depends('line', '_parent_line.bookingtype') + def on_change_with_bookingtype(self, name=None): + """ get type + """ + if self.line: + return self.line.bookingtype + + @fields.depends('line', '_parent_line.cashbook') + def on_change_with_currency(self, name=None): + """ currency of cashbook + """ + if self.line: + return self.line.cashbook.currency.id + + @fields.depends('line', '_parent_line.cashbook') + def on_change_with_currency_digits(self, name=None): + """ currency-digits of cashbook + """ + if self.line: + return self.line.cashbook.currency.digits + else: + return 2 + +# end SplitLine diff --git a/splitline.xml b/splitline.xml new file mode 100644 index 0000000..d2d3f87 --- /dev/null +++ b/splitline.xml @@ -0,0 +1,129 @@ + + + + + + + + cashbook.split + tree + + split_list + + + cashbook.split + form + + split_form + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Administrators: Splitbooking line read/write + + + + + + + + + + + + + + + + + + + + Owners and reviewers: Splitbooking line write + + + + + + + + + + + + + + + + + + + + Observer: Splitbooking line read + + + + + + + + + + + + + + + + + + User in companies + + + + + + + + + + diff --git a/tryton.cfg b/tryton.cfg index 92dec51..dab4bf6 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -16,6 +16,7 @@ xml: configuration.xml book.xml line.xml + splitline.xml wizard_openline.xml wizard_runreport.xml menu.xml diff --git a/view/line_form.xml b/view/line_form.xml index 69b25a3..c0b553b 100644 --- a/view/line_form.xml +++ b/view/line_form.xml @@ -44,6 +44,8 @@ full copyright notices and license terms. --> + + diff --git a/view/split_form.xml b/view/split_form.xml new file mode 100644 index 0000000..3773e8f --- /dev/null +++ b/view/split_form.xml @@ -0,0 +1,18 @@ + + +
+ +