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:
parent
52ffa0536e
commit
8fd6e0d339
7 changed files with 137 additions and 46 deletions
|
@ -13,7 +13,7 @@ class CategoryTestCase(ModuleTestCase):
|
|||
'Test cashbook categoy module'
|
||||
module = 'cashbook'
|
||||
|
||||
def prep_category(self, name='Cat1'):
|
||||
def prep_category(self, name='Cat1', cattype='out'):
|
||||
""" create category
|
||||
"""
|
||||
pool = Pool()
|
||||
|
@ -24,9 +24,57 @@ class CategoryTestCase(ModuleTestCase):
|
|||
category, = Category.create([{
|
||||
'company': company.id,
|
||||
'name': name,
|
||||
'cattype': cattype,
|
||||
}])
|
||||
return category
|
||||
|
||||
@with_transaction()
|
||||
def test_category_create_check_category_type(self):
|
||||
""" create category, update type of category
|
||||
"""
|
||||
pool = Pool()
|
||||
Category = pool.get('cashbook.category')
|
||||
company = self.prep_company()
|
||||
|
||||
category, = Category.create([{
|
||||
'company': company.id,
|
||||
'name': 'Level 1',
|
||||
'cattype': 'in',
|
||||
'childs': [('create', [{
|
||||
'company': company.id,
|
||||
'name': 'Level 2',
|
||||
'cattype': 'in',
|
||||
}])],
|
||||
}])
|
||||
|
||||
self.assertEqual(category.rec_name, 'Level 1')
|
||||
self.assertEqual(category.cattype, 'in')
|
||||
self.assertEqual(len(category.childs), 1)
|
||||
self.assertEqual(category.childs[0].rec_name, 'Level 1/Level 2')
|
||||
self.assertEqual(category.childs[0].cattype, 'in')
|
||||
|
||||
self.assertRaisesRegex(UserError,
|
||||
'The value for field "Type" in "Category" is not valid according to its domain.',
|
||||
Category.write,
|
||||
*[
|
||||
[category.childs[0]],
|
||||
{
|
||||
'cattype': 'out',
|
||||
},
|
||||
])
|
||||
|
||||
Category.write(*[
|
||||
[category],
|
||||
{
|
||||
'cattype': 'out',
|
||||
}])
|
||||
self.assertEqual(category.rec_name, 'Level 1')
|
||||
self.assertEqual(category.cattype, 'out')
|
||||
self.assertEqual(len(category.childs), 1)
|
||||
self.assertEqual(category.childs[0].rec_name, 'Level 1/Level 2')
|
||||
self.assertEqual(category.childs[0].cattype, 'out')
|
||||
|
||||
|
||||
@with_transaction()
|
||||
def test_category_create_nodupl_at_root(self):
|
||||
""" create category, duplicates are allowed at root-level
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue