diff --git a/book.py b/book.py
index 291e81f..fa0fed5 100644
--- a/book.py
+++ b/book.py
@@ -4,7 +4,7 @@
# full copyright notices and license terms.
from trytond.model import Workflow, ModelView, ModelSQL, fields, Check
-from trytond.pyson import Eval, Or, Bool
+from trytond.pyson import Eval, Or, Bool, Id
from trytond.exceptions import UserError
from trytond.i18n import gettext
from trytond.transaction import Transaction
@@ -55,6 +55,19 @@ class Book(Workflow, ModelSQL, ModelView):
reconciliations = fields.One2Many(string='Reconciliations',
field='cashbook', model_name='cashbook.recon',
states=STATES, depends=DEPENDS)
+ number_sequ = fields.Many2One(string='Line numbering', required=True,
+ help='Number sequence for numbering of the cash book lines.',
+ model_name='ir.sequence',
+ domain=[
+ ('sequence_type', '=', Id('cashbook', 'sequence_type_cashbook_line')),
+ ['OR',
+ ('company', '=', None),
+ ('company', '=', Eval('company', -1)),
+ ],
+ ],
+ states=STATES, depends=DEPENDS+['company'])
+ number_atcheck = fields.Boolean(string="number when 'Checking'",
+ help="The numbering of the lines is done in the step Check. If the check mark is inactive, this happens with Done.")
start_balance = fields.Numeric(string='Initial Amount', required=True,
states={
'readonly': Or(
@@ -107,6 +120,14 @@ class Book(Workflow, ModelSQL, ModelView):
},
})
+ @classmethod
+ def default_number_atcheck(cls):
+ return True
+
+ @classmethod
+ def default_start_number(cls):
+ return 1
+
@classmethod
def default_start_balance(cls):
""" zero
diff --git a/book.xml b/book.xml
index 1aecde0..61fba5e 100644
--- a/book.xml
+++ b/book.xml
@@ -156,5 +156,15 @@ full copyright notices and license terms. -->
+
+
+ Cashbook Line
+
+
+
+
+
+
diff --git a/line.py b/line.py
index 5839626..94ad3e8 100644
--- a/line.py
+++ b/line.py
@@ -54,6 +54,7 @@ class Line(Workflow, ModelSQL, ModelView):
states=STATES, depends=DEPENDS)
month = fields.Function(fields.Integer(string='Month', readonly=True),
'on_change_with_month', searcher='search_month')
+ number = fields.Char(string='Number', readonly=True)
description = fields.Text(string='Description',
states=STATES, depends=DEPENDS)
category = fields.Many2One(string='Category',
@@ -218,6 +219,7 @@ class Line(Workflow, ModelSQL, ModelView):
Line2 = pool.get('cashbook.line')
to_create_line = []
+ to_write_line = []
for line in lines:
# deny if date is in range of existing reconciliation
# allow cashbook-line at range-limits
@@ -259,6 +261,18 @@ class Line(Workflow, ModelSQL, ModelView):
'reference': line.id,
})
+ # add number to line
+ if line.cashbook.number_atcheck == True:
+ if len(line.number or '') == 0:
+ to_write_line.extend([
+ [line],
+ {
+ 'number': line.cashbook.number_sequ.get()
+ }])
+
+ if len(to_write_line) > 0:
+ Line2.write(*to_write_line)
+
if len(to_create_line) > 0:
new_lines = Line2.create(to_create_line)
Line2.wfcheck(new_lines)
@@ -269,7 +283,20 @@ class Line(Workflow, ModelSQL, ModelView):
def wfdone(cls, lines):
""" line is done
"""
- pass
+ Line2 = Pool().get('cashbook.line')
+
+ to_write_line = []
+ for line in lines:
+ # add number to line
+ if len(line.number or '') == 0:
+ to_write_line.extend([
+ [line],
+ {
+ 'number': line.cashbook.number_sequ.get()
+ }])
+
+ if len(to_write_line) > 0:
+ Line2.write(*to_write_line)
@classmethod
def default_state(cls):
@@ -508,6 +535,18 @@ class Line(Workflow, ModelSQL, ModelView):
raise ValueError('invalid "bookingtype"')
return {}
+ @classmethod
+ def copy(cls, lines, default=None):
+ """ reset values
+ """
+ if default is None:
+ default = {}
+ else:
+ default = default.copy()
+ default.setdefault('number', None)
+ default.setdefault('state', cls.default_state())
+ return super(Line, cls).copy(moves, default=default)
+
@classmethod
def create(cls, vlist):
""" add debit/credit
diff --git a/locale/de.po b/locale/de.po
index b441bad..9f01e07 100644
--- a/locale/de.po
+++ b/locale/de.po
@@ -299,6 +299,14 @@ msgid "Done"
msgstr "Fertig"
+####################
+# ir.sequence.type #
+####################
+msgctxt "model:ir.sequence.type,name:sequence_type_cashbook_line"
+msgid "Cashbook Line"
+msgstr "Kassenbuchzeile"
+
+
#################
# cashbook.book #
#################
@@ -382,6 +390,22 @@ msgctxt "field:cashbook.book,lines:"
msgid "Lines"
msgstr "Zeilen"
+msgctxt "field:cashbook.book,number_sequ:"
+msgid "Line numbering"
+msgstr "Zeilennummerierung"
+
+msgctxt "help:cashbook.book,number_sequ:"
+msgid "Number sequence for numbering of the cash book lines."
+msgstr "Zahlenfolge zur Nummerierung der Kassenbuchzeilen."
+
+msgctxt "field:cashbook.book,number_atcheck:"
+msgid "number when 'Checking'"
+msgstr "nummerieren beim 'Prüfen'"
+
+msgctxt "help:cashbook.book,number_atcheck:"
+msgid "The numbering of the lines is done in the step Check. If the check mark is inactive, this happens with Done."
+msgstr "Die Nummerierung der Zeilen wird beim Schritt 'Prüfen' erledigt. Bei inaktivem Häkchen passiert dies erst bei 'Fertig'."
+
#################
# cashbook.line #
@@ -550,6 +574,10 @@ msgctxt "selection:cashbook.line,payee:"
msgid "Party"
msgstr "Partei"
+msgctxt "field:cashbook.line,number:"
+msgid "Number"
+msgstr "Nummer"
+
#################
# cashbook.type #
diff --git a/message.xml b/message.xml
index 71fd465..5eef64b 100644
--- a/message.xml
+++ b/message.xml
@@ -93,6 +93,5 @@ full copyright notices and license terms. -->
The current line is managed by the cashbook line '%(recname)s', cashbook: '%(cbook)s'.
-
diff --git a/view/book_form.xml b/view/book_form.xml
index 65ec132..32f201e 100644
--- a/view/book_form.xml
+++ b/view/book_form.xml
@@ -5,12 +5,6 @@ full copyright notices and license terms. -->