splitline: add 'feature' of counterpart

This commit is contained in:
Frederik Jaeckel 2023-01-16 22:01:49 +01:00
parent bd3e63753f
commit a8122666d6
4 changed files with 37 additions and 0 deletions

View file

@ -770,6 +770,10 @@ msgctxt "field:cashbook.split,feature:"
msgid "Feature" msgid "Feature"
msgstr "Merkmal" msgstr "Merkmal"
msgctxt "field:cashbook.split,booktransf_feature:"
msgid "Feature"
msgstr "Merkmal"
################# #################
# cashbook.line # # cashbook.line #
@ -998,6 +1002,10 @@ msgctxt "field:cashbook.line,feature:"
msgid "Feature" msgid "Feature"
msgstr "Merkmal" msgstr "Merkmal"
msgctxt "field:cashbook.line,booktransf_feature:"
msgid "Feature"
msgstr "Merkmal"
################# #################
# cashbook.type # # cashbook.type #

View file

@ -730,6 +730,10 @@ msgctxt "field:cashbook.split,feature:"
msgid "Feature" msgid "Feature"
msgstr "Feature" msgstr "Feature"
msgctxt "field:cashbook.split,booktransf_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"
@ -954,6 +958,10 @@ msgctxt "field:cashbook.line,feature:"
msgid "Feature" msgid "Feature"
msgstr "Feature" msgstr "Feature"
msgctxt "field:cashbook.line,booktransf_feature:"
msgid "Feature"
msgstr "Feature"
msgctxt "model:cashbook.type,name:" msgctxt "model:cashbook.type,name:"
msgid "Cashbook Type" msgid "Cashbook Type"
msgstr "Cashbook Type" msgstr "Cashbook Type"

View file

@ -86,6 +86,8 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
'on_change_with_cashbook') 'on_change_with_cashbook')
feature = fields.Function(fields.Char(string='Feature', readonly=True, feature = fields.Function(fields.Char(string='Feature', readonly=True,
states={'invisible': True}), 'on_change_with_feature') states={'invisible': True}), 'on_change_with_feature')
booktransf_feature = fields.Function(fields.Char(string='Feature', readonly=True,
states={'invisible': True}), 'on_change_with_booktransf_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')
@ -196,6 +198,14 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
if self.line: if self.line:
return self.line.cashbook.btype.feature return self.line.cashbook.btype.feature
@fields.depends('booktransf', '_parent_booktransf.feature')
def on_change_with_booktransf_feature(self, name=None):
""" get 'feature' of counterpart
"""
if self.booktransf:
if self.booktransf.btype:
return self.booktransf.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

View file

@ -62,6 +62,12 @@ class SplitLineTestCase(ModuleTestCase):
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev/Sp|11.00 usd|- [-]') self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev/Sp|11.00 usd|- [-]')
self.assertEqual(book.lines[0].category, None) self.assertEqual(book.lines[0].category, None)
self.assertEqual(len(book.lines[0].splitlines), 2) self.assertEqual(len(book.lines[0].splitlines), 2)
self.assertEqual(book.lines[0].splitlines[0].feature, 'gen')
self.assertEqual(book.lines[0].splitlines[0].booktransf_feature, None)
self.assertEqual(book.lines[0].splitlines[1].feature, 'gen')
self.assertEqual(book.lines[0].splitlines[1].booktransf_feature, None)
self.assertEqual(book.lines[0].splitlines[0].rec_name, self.assertEqual(book.lines[0].splitlines[0].rec_name,
'Rev/Sp|5.00 usd|from category [Cat1]') 'Rev/Sp|5.00 usd|from category [Cat1]')
self.assertEqual(book.lines[0].splitlines[1].rec_name, self.assertEqual(book.lines[0].splitlines[1].rec_name,
@ -137,6 +143,11 @@ class SplitLineTestCase(ModuleTestCase):
self.assertEqual(len(books[1].lines), 0) self.assertEqual(len(books[1].lines), 0)
self.assertEqual(books[0].lines[0].splitlines[0].feature, 'gen') self.assertEqual(books[0].lines[0].splitlines[0].feature, 'gen')
self.assertEqual(books[0].lines[0].splitlines[0].feature, 'gen')
self.assertEqual(books[0].lines[0].splitlines[0].booktransf_feature, None)
self.assertEqual(books[0].lines[0].splitlines[1].feature, 'gen')
self.assertEqual(books[0].lines[0].splitlines[1].booktransf_feature, 'gen')
# wf: edit -> check # wf: edit -> check
Line.wfcheck(books[0].lines) Line.wfcheck(books[0].lines)
self.assertEqual(len(books[0].lines), 1) self.assertEqual(len(books[0].lines), 1)