book: neues Feld 'description', sperrt btype-->None mit Zeilen + Test

line: verwendet nur kassenbücher mit typ
This commit is contained in:
Frederik Jaeckel 2022-09-16 10:15:51 +02:00
parent a2e7f192f8
commit 2acdc55efb
12 changed files with 107 additions and 11 deletions

11
book.py
View file

@ -45,6 +45,8 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
required=True, ondelete="RESTRICT")
name = fields.Char(string='Name', required=True,
states=STATES, depends=DEPENDS)
description = fields.Text(string='Description',
states=STATES, depends=DEPENDS)
btype = fields.Many2One(string='Type',
help='A cash book with type can contain postings. Without type is a view.',
model_name='cashbook.type', ondelete='RESTRICT',
@ -307,6 +309,15 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
actions = iter(args)
for books, values in zip(actions, actions):
for book in books:
# deny btype-->None if lines not empty
if 'btype' in values.keys():
if (values['btype'] is None) and (len(book.lines) > 0):
raise UserError(gettext(
'cashbook.msg_book_btype_with_lines',
cbname = book.rec_name,
numlines = len(book.lines),
))
if book.state != 'open':
# allow state-update, if its the only action
if not (('state' in values.keys()) and (len(values.keys()) == 1)):