line: Feld 'booktransf_feature' + tests

This commit is contained in:
Frederik Jaeckel 2022-12-25 12:08:07 +01:00
parent a051a249e4
commit 7a715d5ea1
5 changed files with 24 additions and 0 deletions

10
line.py
View file

@ -84,6 +84,8 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
'on_change_with_category_view', searcher='search_category_view')
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')
bookingtype = fields.Selection(string='Type', required=True,
help='Type of Booking', selection=sel_bookingtype,
@ -607,6 +609,14 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
if self.cashbook:
return self.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('description')
def on_change_with_descr_short(self, name=None):
""" to speed up list-view

View file

@ -606,6 +606,10 @@ msgctxt "field:cashbook.book,feature:"
msgid "Feature"
msgstr "Merkmal"
msgctxt "field:cashbook.book,booktransf_feature:"
msgid "Feature"
msgstr "Merkmal"
##################
# cashbook.split #

View file

@ -570,6 +570,10 @@ msgctxt "field:cashbook.book,feature:"
msgid "Feature"
msgstr "Feature"
msgctxt "field:cashbook.book,booktransf_feature:"
msgid "Feature"
msgstr "Feature"
msgctxt "model:cashbook.split,name:"
msgid "Split booking line"
msgstr "Split booking line"

View file

@ -995,6 +995,11 @@ class LineTestCase(ModuleTestCase):
self.assertEqual(book.lines[0].rec_name, '05/01/2022|to|-1.00 usd|Transfer Out [Book 2 | 0.00 usd | Open]')
self.assertEqual(len(book.lines[0].references), 0)
# check counterpart
self.assertEqual(book.lines[0].booktransf.rec_name, 'Book 2 | 0.00 usd | Open')
self.assertEqual(book.lines[0].booktransf.btype.feature, 'gen')
self.assertEqual(book.lines[0].booktransf_feature, 'gen')
# check payee
self.assertEqual(book.lines[0].payee.rec_name, 'Book 2 | 0.00 usd | Open')
self.assertEqual(Line.search_count([('payee', 'ilike', 'book 2%')]), 1)

View file

@ -59,4 +59,5 @@ full copyright notices and license terms. -->
<field name="owner_cashbook"/>
<field name="feature"/>
<field name="booktransf_feature"/>
</form>