kategorie: sperrt 'Typ' wenn parent existiert, korrekte Anpassung

der sub-kategorien bei Änderung + test
Line: Kategoriefeld prüft Inhalt + tests
This commit is contained in:
Frederik Jaeckel 2022-08-11 11:06:28 +02:00
parent 52ffa0536e
commit 8fd6e0d339
7 changed files with 137 additions and 46 deletions

View file

@ -25,7 +25,7 @@ class LineTestCase(ModuleTestCase):
Lines = pool.get('cashbook.line')
types = self.prep_type()
category = self.prep_category()
category = self.prep_category(cattype='in')
company = self.prep_company()
book, = Book.create([{
'name': 'Book 1',
@ -102,7 +102,7 @@ class LineTestCase(ModuleTestCase):
Line = pool.get('cashbook.line')
types = self.prep_type()
category = self.prep_category()
category = self.prep_category(cattype='in')
company = self.prep_company()
book, = Book.create([{
'name': 'Book 1',
@ -150,7 +150,7 @@ class LineTestCase(ModuleTestCase):
IrDate = pool.get('ir.date')
types = self.prep_type()
category = self.prep_category()
category = self.prep_category(cattype='in')
company = self.prep_company()
IrDate.today = MagicMock(return_value=date(2022, 6, 1))
@ -214,14 +214,10 @@ class LineTestCase(ModuleTestCase):
Category = pool.get('cashbook.category')
types = self.prep_type()
category = self.prep_category()
category_in = self.prep_category(cattype='in')
category_out = self.prep_category(name='Out Category', cattype='out')
company = self.prep_company()
category2, = Category.create([{
'company': company.id,
'name': 'Category',
}])
book, = Book.create([{
'name': 'Book 1',
'btype': types.id,
@ -230,25 +226,25 @@ class LineTestCase(ModuleTestCase):
'lines': [('create', [{
'date': date(2022, 5, 1),
'description': 'Revenue',
'category': category2.id,
'category': category_in.id,
'bookingtype': 'in',
'amount': Decimal('1.0'),
}, {
'date': date(2022, 6, 1),
'description': 'Expense',
'category': category2.id,
'category': category_out.id,
'bookingtype': 'out',
'amount': Decimal('1.0'),
}, {
'date': date(2022, 6, 1),
'description': 'Transfer from',
'category': category2.id,
'category': category_in.id,
'bookingtype': 'mvin',
'amount': Decimal('1.0'),
}, {
'date': date(2022, 6, 1),
'description': 'Transfer to',
'category': category2.id,
'category': category_out.id,
'bookingtype': 'mvout',
'amount': Decimal('1.0'),
}])],
@ -291,6 +287,7 @@ class LineTestCase(ModuleTestCase):
[book.lines[0]],
{
'bookingtype': 'out',
'category': category_out.id,
}])
self.assertEqual(book.lines[0].amount, Decimal('2.0'))
self.assertEqual(book.lines[0].bookingtype, 'out')
@ -300,6 +297,7 @@ class LineTestCase(ModuleTestCase):
Line.write(*[
[book.lines[0]],
{
'category': category_in.id,
'bookingtype': 'mvin',
'amount': Decimal('3.0'),
}])
@ -320,7 +318,7 @@ class LineTestCase(ModuleTestCase):
Account = pool.get('account.account')
types = self.prep_type()
category = self.prep_category()
category = self.prep_category(cattype='in')
company = self.prep_company()
with Transaction().set_context({
@ -340,10 +338,12 @@ class LineTestCase(ModuleTestCase):
'company': company.id,
'name': 'Level1',
'account': accounts[0].id,
'cattype': 'in',
'childs': [('create', [{
'company': company.id,
'name': 'Level2',
'account': accounts[1].id,
'cattype': 'in',
}])],
}])
self.assertEqual(category2.rec_name, 'Level1 [0123]')
@ -414,7 +414,7 @@ class LineTestCase(ModuleTestCase):
Lines = pool.get('cashbook.line')
types = self.prep_type()
category = self.prep_category()
category = self.prep_category(cattype='in')
company = self.prep_company()
book, = Book.create([{
'name': 'Book 1',
@ -450,7 +450,7 @@ class LineTestCase(ModuleTestCase):
Lines = pool.get('cashbook.line')
types = self.prep_type()
category = self.prep_category()
category = self.prep_category(cattype='in')
company = self.prep_company()
book, = Book.create([{
'name': 'Book 1',
@ -491,7 +491,7 @@ class LineTestCase(ModuleTestCase):
Lines = pool.get('cashbook.line')
types = self.prep_type()
category = self.prep_category()
category = self.prep_category(cattype='in')
company = self.prep_company()
book, = Book.create([{
'name': 'Book 1',
@ -536,7 +536,7 @@ class LineTestCase(ModuleTestCase):
Line = pool.get('cashbook.line')
types = self.prep_type()
category = self.prep_category()
category = self.prep_category(cattype='in')
company = self.prep_company()
grp_cashbook, = ResGroup.search([('name', '=', 'Cashbook')])
usr_lst = ResUser.create([{
@ -606,7 +606,7 @@ class LineTestCase(ModuleTestCase):
Line = pool.get('cashbook.line')
types = self.prep_type()
category = self.prep_category()
category = self.prep_category(cattype='in')
company = self.prep_company()
grp_cashbook, = ResGroup.search([('name', '=', 'Cashbook')])
grp_reviewer, = ResGroup.create([{
@ -690,7 +690,7 @@ class LineTestCase(ModuleTestCase):
Line = pool.get('cashbook.line')
types = self.prep_type()
category = self.prep_category()
category = self.prep_category(cattype='in')
company = self.prep_company()
grp_cashbook, = ResGroup.search([('name', '=', 'Cashbook')])
grp_observer, = ResGroup.create([{