splitline: add-2nd-unit-values extendable, new field 'feature'
This commit is contained in:
parent
11d6183d65
commit
82ae7d7bca
6 changed files with 36 additions and 8 deletions
|
@ -766,6 +766,10 @@ msgctxt "help:cashbook.split,rate_2nd_currency:"
|
||||||
msgid "Exchange rate between the currencies of the participating cashbooks."
|
msgid "Exchange rate between the currencies of the participating cashbooks."
|
||||||
msgstr "Wechselkurs zwischen der Währungen der beteiligten Kassenbücher."
|
msgstr "Wechselkurs zwischen der Währungen der beteiligten Kassenbücher."
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.split,feature:"
|
||||||
|
msgid "Feature"
|
||||||
|
msgstr "Merkmal"
|
||||||
|
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# cashbook.line #
|
# cashbook.line #
|
||||||
|
|
|
@ -726,6 +726,10 @@ msgctxt "help:cashbook.split,rate_2nd_currency:"
|
||||||
msgid "Exchange rate between the currencies of the participating cashbooks."
|
msgid "Exchange rate between the currencies of the participating cashbooks."
|
||||||
msgstr "Exchange rate between the currencies of the participating cashbooks."
|
msgstr "Exchange rate between the currencies of the participating cashbooks."
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.split,feature:"
|
||||||
|
msgid "Feature"
|
||||||
|
msgstr "Feature"
|
||||||
|
|
||||||
msgctxt "model:cashbook.line,name:"
|
msgctxt "model:cashbook.line,name:"
|
||||||
msgid "Cashbook Line"
|
msgid "Cashbook Line"
|
||||||
msgstr "Cashbook Line"
|
msgstr "Cashbook Line"
|
||||||
|
|
27
splitline.py
27
splitline.py
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# This file is part of the cashbook-module from m-ds for Tryton.
|
# This file is part of the cashbook-module from m-ds.de for Tryton.
|
||||||
# The COPYRIGHT file at the top level of this repository contains the
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
@ -84,6 +84,8 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
||||||
cashbook = fields.Function(fields.Many2One(string='Cashbook',
|
cashbook = fields.Function(fields.Many2One(string='Cashbook',
|
||||||
readonly=True, states={'invisible': True}, model_name='cashbook.book'),
|
readonly=True, states={'invisible': True}, model_name='cashbook.book'),
|
||||||
'on_change_with_cashbook')
|
'on_change_with_cashbook')
|
||||||
|
feature = fields.Function(fields.Char(string='Feature', readonly=True,
|
||||||
|
states={'invisible': True}), 'on_change_with_feature')
|
||||||
state_cashbook = fields.Function(fields.Selection(string='State of Cashbook',
|
state_cashbook = fields.Function(fields.Selection(string='State of Cashbook',
|
||||||
readonly=True, states={'invisible': True}, selection=sel_state_book),
|
readonly=True, states={'invisible': True}, selection=sel_state_book),
|
||||||
'on_change_with_state_cashbook')
|
'on_change_with_state_cashbook')
|
||||||
|
@ -187,6 +189,13 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
||||||
if self.line:
|
if self.line:
|
||||||
return self.line.bookingtype
|
return self.line.bookingtype
|
||||||
|
|
||||||
|
@fields.depends('line', '_parent_line.cashbook')
|
||||||
|
def on_change_with_feature(self, name=None):
|
||||||
|
""" get feature-set
|
||||||
|
"""
|
||||||
|
if self.line:
|
||||||
|
return self.line.cashbook.btype.feature
|
||||||
|
|
||||||
@fields.depends('line', '_parent_line.cashbook')
|
@fields.depends('line', '_parent_line.cashbook')
|
||||||
def on_change_with_currency(self, name=None):
|
def on_change_with_currency(self, name=None):
|
||||||
""" currency of cashbook
|
""" currency of cashbook
|
||||||
|
@ -203,6 +212,17 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
||||||
else:
|
else:
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def add_2nd_unit_values(cls, values):
|
||||||
|
""" extend create-values
|
||||||
|
"""
|
||||||
|
Line2 = Pool().get('cashbook.line')
|
||||||
|
line = Line2(values.get('line', None))
|
||||||
|
|
||||||
|
if line:
|
||||||
|
values.update(cls.add_2nd_currency(values, line.cashbook.currency))
|
||||||
|
return values
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, vlist):
|
def create(cls, vlist):
|
||||||
""" add debit/credit
|
""" add debit/credit
|
||||||
|
@ -211,10 +231,7 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
||||||
|
|
||||||
vlist = [x.copy() for x in vlist]
|
vlist = [x.copy() for x in vlist]
|
||||||
for values in vlist:
|
for values in vlist:
|
||||||
line = Line2(values.get('line', None))
|
values.update(cls.add_2nd_unit_values(values))
|
||||||
if line:
|
|
||||||
values.update(cls.add_2nd_currency(values, line.cashbook.currency))
|
|
||||||
|
|
||||||
records = super(SplitLine, cls).create(vlist)
|
records = super(SplitLine, cls).create(vlist)
|
||||||
|
|
||||||
to_update_line = []
|
to_update_line = []
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# This file is part of the cashbook-module from m-ds for Tryton.
|
# This file is part of the cashbook-module from m-ds.de for Tryton.
|
||||||
# The COPYRIGHT file at the top level of this repository contains the
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ class SplitLineTestCase(ModuleTestCase):
|
||||||
self.assertEqual(books[0].lines[0].splitlines[1].rec_name,
|
self.assertEqual(books[0].lines[0].splitlines[1].rec_name,
|
||||||
'Rev/Sp|6.00 usd|from cashbook [Book 2 | 0.00 usd | Open]')
|
'Rev/Sp|6.00 usd|from cashbook [Book 2 | 0.00 usd | Open]')
|
||||||
self.assertEqual(len(books[1].lines), 0)
|
self.assertEqual(len(books[1].lines), 0)
|
||||||
|
self.assertEqual(books[0].lines[0].splitlines[0].feature, 'gen')
|
||||||
|
|
||||||
# wf: edit -> check
|
# wf: edit -> check
|
||||||
Line.wfcheck(books[0].lines)
|
Line.wfcheck(books[0].lines)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!-- This file is part of the cashbook-module from m-ds for Tryton.
|
<!-- This file is part of the cashbook-module from m-ds.de for Tryton.
|
||||||
The COPYRIGHT file at the top level of this repository contains the
|
The COPYRIGHT file at the top level of this repository contains the
|
||||||
full copyright notices and license terms. -->
|
full copyright notices and license terms. -->
|
||||||
<form col="4">
|
<form col="4">
|
||||||
|
@ -27,4 +27,5 @@ full copyright notices and license terms. -->
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
|
<field name="feature"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!-- This file is part of the cashbook-module from m-ds for Tryton.
|
<!-- This file is part of the cashbook-module from m-ds.de for Tryton.
|
||||||
The COPYRIGHT file at the top level of this repository contains the
|
The COPYRIGHT file at the top level of this repository contains the
|
||||||
full copyright notices and license terms. -->
|
full copyright notices and license terms. -->
|
||||||
<tree editable="1">
|
<tree editable="1">
|
||||||
<field name="line" tree_invisible="1"/>
|
<field name="line" tree_invisible="1"/>
|
||||||
|
<field name="feature" tree_invisible="1"/>
|
||||||
<field name="splittype"/>
|
<field name="splittype"/>
|
||||||
<field name="category"/>
|
<field name="category"/>
|
||||||
<field name="booktransf"/>
|
<field name="booktransf"/>
|
||||||
|
|
Loading…
Reference in a new issue