line/book: sequence für zeilen-nummerierung
This commit is contained in:
parent
5fdbb0ce89
commit
a801775880
8 changed files with 128 additions and 17 deletions
23
book.py
23
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
|
||||
|
|
10
book.xml
10
book.xml
|
@ -156,5 +156,15 @@ full copyright notices and license terms. -->
|
|||
<field name="group" ref="res.group_admin"/>
|
||||
</record>
|
||||
|
||||
<!-- sequence-type -->
|
||||
<record model="ir.sequence.type" id="sequence_type_cashbook_line">
|
||||
<field name="name">Cashbook Line</field>
|
||||
</record>
|
||||
<record model="ir.sequence.type-res.group"
|
||||
id="sequence_type_cashbook_line-group_admin">
|
||||
<field name="sequence_type" ref="sequence_type_cashbook_line"/>
|
||||
<field name="group" ref="res.group_admin"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
41
line.py
41
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
|
||||
|
|
28
locale/de.po
28
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 #
|
||||
|
|
|
@ -93,6 +93,5 @@ full copyright notices and license terms. -->
|
|||
<field name="text">The current line is managed by the cashbook line '%(recname)s', cashbook: '%(cbook)s'.</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
|
@ -5,12 +5,6 @@ full copyright notices and license terms. -->
|
|||
<form col="6">
|
||||
<label name="name"/>
|
||||
<field name="name" colspan="3"/>
|
||||
<label name="btype"/>
|
||||
<field name="btype"/>
|
||||
|
||||
<label name="currency"/>
|
||||
<field name="currency"/>
|
||||
<label id="phaccount" colspan="2" string=" "/>
|
||||
<group id="grpst" colspan="2" col="3">
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
|
@ -21,6 +15,20 @@ full copyright notices and license terms. -->
|
|||
</group>
|
||||
</group>
|
||||
|
||||
<label name="number_sequ"/>
|
||||
<field name="number_sequ"/>
|
||||
<label name="number_atcheck"/>
|
||||
<field name="number_atcheck"/>
|
||||
<newline/>
|
||||
|
||||
<label name="btype"/>
|
||||
<field name="btype"/>
|
||||
<label name="currency"/>
|
||||
<field name="currency"/>
|
||||
<newline/>
|
||||
<label id="phaccount" colspan="2" string=" "/>
|
||||
<newline/>
|
||||
|
||||
<label name="start_balance"/>
|
||||
<field name="start_balance"/>
|
||||
<label name="balance"/>
|
||||
|
|
|
@ -7,12 +7,8 @@ full copyright notices and license terms. -->
|
|||
<separator name="state" colspan="2" string="State"/>
|
||||
|
||||
<field name="cashbook" colspan="2"/>
|
||||
<group id="grpparty" colspan="2" col="4">
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="booktransf"/>
|
||||
<field name="booktransf"/>
|
||||
</group>
|
||||
<label name="number"/>
|
||||
<field name="number"/>
|
||||
|
||||
<field name="state"/>
|
||||
<group id="grpstate" col="2">
|
||||
|
@ -27,10 +23,19 @@ full copyright notices and license terms. -->
|
|||
<label name="reconciliation"/>
|
||||
<field name="reconciliation"/>
|
||||
|
||||
<label name="category"/>
|
||||
<field name="category"/>
|
||||
<group id="grpparty" colspan="2" col="4">
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="booktransf"/>
|
||||
<field name="booktransf"/>
|
||||
</group>
|
||||
<label name="amount"/>
|
||||
<field name="amount" symbol="currency"/>
|
||||
<newline/>
|
||||
|
||||
<label name="category"/>
|
||||
<field name="category"/>
|
||||
<newline/>
|
||||
|
||||
<group name="description" colspan="4" col="1" string="Description">
|
||||
<field name="description"/>
|
||||
|
|
|
@ -4,6 +4,7 @@ The COPYRIGHT file at the top level of this repository contains the
|
|||
full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="cashbook" tree_invisible="1"/>
|
||||
<field name="number"/>
|
||||
<field name="date"/>
|
||||
<field name="payee"/>
|
||||
<field name="category_view"/>
|
||||
|
|
Loading…
Reference in a new issue