line: suche in splitline (kategorie+beschreibung)
This commit is contained in:
parent
2a44c67ccf
commit
86922aecef
2 changed files with 47 additions and 6 deletions
2
line.py
2
line.py
|
@ -357,6 +357,8 @@ class Line(Workflow, ModelSQL, ModelView):
|
||||||
return cls.search_payee(name, clause) + [
|
return cls.search_payee(name, clause) + [
|
||||||
('description',) + tuple(clause[1:]),
|
('description',) + tuple(clause[1:]),
|
||||||
('category.rec_name',) + tuple(clause[1:]),
|
('category.rec_name',) + tuple(clause[1:]),
|
||||||
|
('splitlines.description',) + tuple(clause[1:]),
|
||||||
|
('splitlines.category.rec_name',) + tuple(clause[1:]),
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_rec_name(self, name):
|
def get_rec_name(self, name):
|
||||||
|
|
|
@ -460,10 +460,18 @@ class LineTestCase(ModuleTestCase):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Book = pool.get('cashbook.book')
|
Book = pool.get('cashbook.book')
|
||||||
Lines = pool.get('cashbook.line')
|
Lines = pool.get('cashbook.line')
|
||||||
|
Category = pool.get('cashbook.category')
|
||||||
|
|
||||||
types = self.prep_type()
|
types = self.prep_type()
|
||||||
category = self.prep_category(cattype='in')
|
|
||||||
company = self.prep_company()
|
company = self.prep_company()
|
||||||
|
category = self.prep_category(cattype='in')
|
||||||
|
category2, = Category.create([{
|
||||||
|
'name': 'sp-cat1',
|
||||||
|
'cattype': 'in',
|
||||||
|
'company': company.id,
|
||||||
|
}])
|
||||||
|
self.assertEqual(category2.rec_name, 'sp-cat1')
|
||||||
|
|
||||||
party = self.prep_party()
|
party = self.prep_party()
|
||||||
book, = Book.create([{
|
book, = Book.create([{
|
||||||
'name': 'Book 1',
|
'name': 'Book 1',
|
||||||
|
@ -486,33 +494,60 @@ class LineTestCase(ModuleTestCase):
|
||||||
'bookingtype': 'in',
|
'bookingtype': 'in',
|
||||||
'amount': Decimal('1.0'),
|
'amount': Decimal('1.0'),
|
||||||
'party': party.id,
|
'party': party.id,
|
||||||
|
}, {
|
||||||
|
'date': date(2022, 5, 3),
|
||||||
|
'description': 'Text 3',
|
||||||
|
'bookingtype': 'spin',
|
||||||
|
'amount': Decimal('1.0'),
|
||||||
|
'party': party.id,
|
||||||
|
'splitlines': [('create', [{
|
||||||
|
'amount': Decimal('1.0'),
|
||||||
|
'description': 'text3-spline1',
|
||||||
|
'category': category2.id,
|
||||||
|
}])],
|
||||||
}])],
|
}])],
|
||||||
}])
|
}])
|
||||||
self.assertEqual(book.name, 'Book 1')
|
self.assertEqual(book.name, 'Book 1')
|
||||||
self.assertEqual(book.btype.rec_name, 'CAS - Cash')
|
self.assertEqual(book.btype.rec_name, 'CAS - Cash')
|
||||||
self.assertEqual(book.state, 'open')
|
self.assertEqual(book.state, 'open')
|
||||||
self.assertEqual(len(book.lines), 2)
|
self.assertEqual(len(book.lines), 3)
|
||||||
self.assertEqual(book.lines[0].date, date(2022, 5, 1))
|
self.assertEqual(book.lines[0].date, date(2022, 5, 1))
|
||||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||||
self.assertEqual(book.lines[0].state_cashbook, 'open')
|
self.assertEqual(book.lines[0].state_cashbook, 'open')
|
||||||
self.assertEqual(book.lines[1].date, date(2022, 5, 2))
|
self.assertEqual(book.lines[1].date, date(2022, 5, 2))
|
||||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||||
|
self.assertEqual(book.lines[2].date, date(2022, 5, 3))
|
||||||
|
self.assertEqual(book.lines[2].rec_name, '05/03/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||||
|
|
||||||
self.assertEqual(Lines.search_count([('rec_name', '=', 'Text 1')]), 1)
|
self.assertEqual(Lines.search_count([('rec_name', '=', 'Text 1')]), 1)
|
||||||
self.assertEqual(Lines.search_count([('rec_name', '=', 'Text 1a')]), 0)
|
self.assertEqual(Lines.search_count([('rec_name', '=', 'Text 1a')]), 0)
|
||||||
self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'text%')]), 2)
|
self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'text%')]), 3)
|
||||||
|
# search in category of split-line
|
||||||
|
self.assertEqual(Lines.search_count([('rec_name', '=', 'sp-cat1')]), 1)
|
||||||
|
# search in description of split-line
|
||||||
|
self.assertEqual(Lines.search_count([('rec_name', '=', 'text3-spline1')]), 1)
|
||||||
|
# ilike fails in fields.Text to find subtext...
|
||||||
|
self.assertEqual(Lines.search_count([('rec_name', 'ilike', '%spline%')]), 0)
|
||||||
|
# ...but it uses separator-chars
|
||||||
|
self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'text3%')]), 1)
|
||||||
|
self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'spline1')]), 1)
|
||||||
|
self.assertEqual(Lines.search_count([('rec_name', 'ilike', '%spline1')]), 1)
|
||||||
|
self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'spline1%')]), 0)
|
||||||
|
self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'text3')]), 1)
|
||||||
|
|
||||||
self.assertEqual(Lines.search_count([('state_cashbook', '=', 'open')]), 2)
|
self.assertEqual(Lines.search_count([('state_cashbook', '=', 'open')]), 3)
|
||||||
self.assertEqual(Lines.search_count([('state_cashbook', '=', 'closed')]), 0)
|
self.assertEqual(Lines.search_count([('state_cashbook', '=', 'closed')]), 0)
|
||||||
self.assertEqual(Lines.search_count([('cashbook.state', '=', 'open')]), 2)
|
self.assertEqual(Lines.search_count([('cashbook.state', '=', 'open')]), 3)
|
||||||
self.assertEqual(Lines.search_count([('cashbook.state', '=', 'closed')]), 0)
|
self.assertEqual(Lines.search_count([('cashbook.state', '=', 'closed')]), 0)
|
||||||
|
|
||||||
# sorting: date -> state -> id
|
# sorting: date -> state -> id
|
||||||
self.assertEqual(len(book.lines), 2)
|
self.assertEqual(len(book.lines), 3)
|
||||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||||
self.assertEqual(book.lines[0].state, 'edit')
|
self.assertEqual(book.lines[0].state, 'edit')
|
||||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||||
self.assertEqual(book.lines[1].state, 'edit')
|
self.assertEqual(book.lines[1].state, 'edit')
|
||||||
|
self.assertEqual(book.lines[2].rec_name, '05/03/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||||
|
self.assertEqual(book.lines[2].state, 'edit')
|
||||||
|
|
||||||
# set to same date
|
# set to same date
|
||||||
Lines.write(*[
|
Lines.write(*[
|
||||||
|
@ -526,6 +561,8 @@ class LineTestCase(ModuleTestCase):
|
||||||
self.assertEqual(book.lines[0].state, 'edit')
|
self.assertEqual(book.lines[0].state, 'edit')
|
||||||
self.assertEqual(book.lines[1].rec_name, '05/01/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
self.assertEqual(book.lines[1].rec_name, '05/01/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||||
self.assertEqual(book.lines[1].state, 'edit')
|
self.assertEqual(book.lines[1].state, 'edit')
|
||||||
|
self.assertEqual(book.lines[2].rec_name, '05/01/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||||
|
self.assertEqual(book.lines[2].state, 'edit')
|
||||||
|
|
||||||
# set to 'check', will sort first
|
# set to 'check', will sort first
|
||||||
Lines.wfcheck([book.lines[1]])
|
Lines.wfcheck([book.lines[1]])
|
||||||
|
@ -534,6 +571,8 @@ class LineTestCase(ModuleTestCase):
|
||||||
self.assertEqual(book.lines[0].state, 'check')
|
self.assertEqual(book.lines[0].state, 'check')
|
||||||
self.assertEqual(book.lines[1].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
self.assertEqual(book.lines[1].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||||
self.assertEqual(book.lines[1].state, 'edit')
|
self.assertEqual(book.lines[1].state, 'edit')
|
||||||
|
self.assertEqual(book.lines[2].rec_name, '05/01/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||||
|
self.assertEqual(book.lines[2].state, 'edit')
|
||||||
|
|
||||||
@with_transaction()
|
@with_transaction()
|
||||||
def test_line_create_check_deny_write(self):
|
def test_line_create_check_deny_write(self):
|
||||||
|
|
Loading…
Reference in a new issue