diff --git a/locale/de.po b/locale/de.po index fcb921e..6413c85 100644 --- a/locale/de.po +++ b/locale/de.po @@ -770,6 +770,10 @@ msgctxt "field:cashbook.split,feature:" msgid "Feature" msgstr "Merkmal" +msgctxt "field:cashbook.split,booktransf_feature:" +msgid "Feature" +msgstr "Merkmal" + ################# # cashbook.line # @@ -998,6 +1002,10 @@ msgctxt "field:cashbook.line,feature:" msgid "Feature" msgstr "Merkmal" +msgctxt "field:cashbook.line,booktransf_feature:" +msgid "Feature" +msgstr "Merkmal" + ################# # cashbook.type # diff --git a/locale/en.po b/locale/en.po index 9e2e211..d83e5c4 100644 --- a/locale/en.po +++ b/locale/en.po @@ -730,6 +730,10 @@ msgctxt "field:cashbook.split,feature:" msgid "Feature" msgstr "Feature" +msgctxt "field:cashbook.split,booktransf_feature:" +msgid "Feature" +msgstr "Feature" + msgctxt "model:cashbook.line,name:" msgid "Cashbook Line" msgstr "Cashbook Line" @@ -954,6 +958,10 @@ msgctxt "field:cashbook.line,feature:" msgid "Feature" msgstr "Feature" +msgctxt "field:cashbook.line,booktransf_feature:" +msgid "Feature" +msgstr "Feature" + msgctxt "model:cashbook.type,name:" msgid "Cashbook Type" msgstr "Cashbook Type" diff --git a/splitline.py b/splitline.py index e0e38ca..3f73531 100644 --- a/splitline.py +++ b/splitline.py @@ -86,6 +86,8 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView): 'on_change_with_cashbook') feature = fields.Function(fields.Char(string='Feature', readonly=True, 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', readonly=True, states={'invisible': True}, selection=sel_state_book), 'on_change_with_state_cashbook') @@ -196,6 +198,14 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView): if self.line: 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') def on_change_with_currency(self, name=None): """ currency of cashbook diff --git a/tests/test_splitline.py b/tests/test_splitline.py index 9d90705..0b4e8d3 100644 --- a/tests/test_splitline.py +++ b/tests/test_splitline.py @@ -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].category, None) 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, 'Rev/Sp|5.00 usd|from category [Cat1]') 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(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 Line.wfcheck(books[0].lines) self.assertEqual(len(books[0].lines), 1)