formatting, line: test for delete of party

This commit is contained in:
Frederik Jaeckel 2023-05-18 12:15:53 +02:00
parent 78f160bf0b
commit 619a17bcd6
16 changed files with 701 additions and 516 deletions

View file

@ -811,6 +811,49 @@ class LineTestCase(ModuleTestCase):
'amount': Decimal('0.0'),
}])
@with_transaction()
def test_line_check_deny_delete_of_party(self):
""" create cashbook + line, delete party should fail
"""
pool = Pool()
Book = pool.get('cashbook.book')
Line = pool.get('cashbook.line')
Party = pool.get('party.party')
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': 'Text 1',
'category': category.id,
'bookingtype': 'in',
'amount': Decimal('1.0'),
'party': party.id,
}])],
}])
self.assertEqual(book.name, 'Book 1')
self.assertEqual(book.state, 'open')
self.assertEqual(len(book.lines), 1)
self.assertEqual(book.lines[0].party.rec_name, 'Party')
self.assertEqual(book.lines[0].party.id, party.id)
self.assertEqual(Party.search_count([('name', '=', 'Party')]), 1)
self.assertRaisesRegex(
UserError,
'The records could not be deleted because they are used by field "Party" of "Cashbook Line".',
Party.delete,
[party])
@with_transaction()
def test_line_create_check_deny_write(self):
""" create cashbook + line, 'close' book, write to line