book: neues Feld 'description', sperrt btype-->None mit Zeilen + Test
line: verwendet nur kassenbücher mit typ
This commit is contained in:
parent
a2e7f192f8
commit
2acdc55efb
12 changed files with 107 additions and 11 deletions
|
@ -117,6 +117,62 @@ class BookTestCase(ModuleTestCase):
|
|||
Book.delete,
|
||||
[book])
|
||||
|
||||
@with_transaction()
|
||||
def test_book_deny_btype_set_none(self):
|
||||
""" create cashbook, add lines,
|
||||
try to set btype to None with lines
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
|
||||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
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,
|
||||
'start_date': date(2022, 5, 1),
|
||||
'lines': [('create', [{
|
||||
'date': date(2022, 5, 1),
|
||||
'description': 'test 1',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.btype.rec_name, 'CAS - Cash')
|
||||
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The type cannot be deleted on the cash book 'Book 1 | 1.00 usd | Open' because it still contains 1 lines.",
|
||||
Book.write,
|
||||
*[
|
||||
[book],
|
||||
{
|
||||
'btype': None,
|
||||
},
|
||||
])
|
||||
|
||||
Book.write(*[
|
||||
[book],
|
||||
{
|
||||
'lines': [('delete', [book.lines[0].id])],
|
||||
}])
|
||||
self.assertEqual(len(book.lines), 0)
|
||||
self.assertEqual(book.btype.rec_name, 'CAS - Cash')
|
||||
|
||||
Book.write(*[
|
||||
[book],
|
||||
{
|
||||
'btype': None,
|
||||
}])
|
||||
self.assertEqual(book.btype, None)
|
||||
|
||||
@with_transaction()
|
||||
def test_book_deny_delete_closed(self):
|
||||
""" create cashbook, add lines, try to delete in state 'closed'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue