book: hierarchie + test
book: Feld 'start_balance' entfernt
This commit is contained in:
parent
57ade40eb8
commit
8421db2221
16 changed files with 319 additions and 168 deletions
|
@ -51,10 +51,37 @@ class BookTestCase(ModuleTestCase):
|
|||
'number_sequ': self.prep_sequence().id,
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.rec_name, 'Book 1 | 0.00 usd | Open')
|
||||
self.assertEqual(book.btype.rec_name, 'CAS - Cash')
|
||||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(book.state_string, 'Open')
|
||||
|
||||
@with_transaction()
|
||||
def test_book_create_hierarchy(self):
|
||||
""" create cashbook, hierarchical
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
|
||||
types = self.prep_type()
|
||||
company = self.prep_company()
|
||||
book, = Book.create([{
|
||||
'name': 'Level 1',
|
||||
'btype': None,
|
||||
'company': company.id,
|
||||
'childs': [('create', [{
|
||||
'name': 'Level 2',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Level 1')
|
||||
self.assertEqual(book.rec_name, 'Level 1')
|
||||
self.assertEqual(len(book.childs), 1)
|
||||
self.assertEqual(book.childs[0].rec_name, 'Level 1/Level 2 | 0.00 usd | Open')
|
||||
|
||||
@with_transaction()
|
||||
def test_book_deny_delete_open(self):
|
||||
""" create cashbook, add lines, try to delete in state 'open'
|
||||
|
@ -225,62 +252,6 @@ class BookTestCase(ModuleTestCase):
|
|||
},
|
||||
])
|
||||
|
||||
@with_transaction()
|
||||
def test_book_deny_update_start_amount(self):
|
||||
""" create cashbook, add lines, update start-amount
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
|
||||
types = self.prep_type()
|
||||
company = self.prep_company()
|
||||
category = self.prep_category(cattype='in')
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.start_balance, Decimal('0.0'))
|
||||
self.assertEqual(book.rec_name, 'Book 1 | 0.00 usd | Open')
|
||||
|
||||
Book.write(*[
|
||||
[book],
|
||||
{
|
||||
'start_balance': Decimal('1.0'),
|
||||
}])
|
||||
self.assertEqual(book.start_balance, Decimal('1.0'))
|
||||
self.assertEqual(book.balance, Decimal('1.0'))
|
||||
|
||||
Book.write(*[
|
||||
[book],
|
||||
{
|
||||
'lines': [('create', [{
|
||||
'amount': Decimal('2.0'),
|
||||
'description': 'Test',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.start_balance, Decimal('1.0'))
|
||||
self.assertEqual(book.balance, Decimal('3.0'))
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(book.lines[0].balance, Decimal('3.0'))
|
||||
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The initial amount of the cash book 'Fridas book | 3.00 usd | Open' cannot be changed because it already contains bookings.",
|
||||
Book.write,
|
||||
*[
|
||||
[book],
|
||||
{
|
||||
'start_balance': Decimal('1.5'),
|
||||
},
|
||||
])
|
||||
|
||||
@with_transaction()
|
||||
def test_book_permission_owner(self):
|
||||
""" create book + 2x users, add users to group, check access
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue