konfig/buchung eingeben: ausgewählte kassenbücher
This commit is contained in:
parent
2acdc55efb
commit
99abc069d8
6 changed files with 282 additions and 7 deletions
18
book.py
18
book.py
|
@ -306,7 +306,10 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
def write(cls, *args):
|
||||
""" deny update if book is not 'open'
|
||||
"""
|
||||
ConfigUser = Pool().get('cashbook.configuration_user')
|
||||
|
||||
actions = iter(args)
|
||||
to_write_config = []
|
||||
for books, values in zip(actions, actions):
|
||||
for book in books:
|
||||
# deny btype-->None if lines not empty
|
||||
|
@ -326,8 +329,23 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
bookname = book.rec_name,
|
||||
state_txt = book.state_string,
|
||||
))
|
||||
|
||||
# if owner changes, remove book from user-config
|
||||
if 'owner' in values.keys():
|
||||
if book.owner.id != values['owner']:
|
||||
for x in ['defbook', 'book1', 'book2', 'book3',
|
||||
'book4', 'book5']:
|
||||
cfg1 = ConfigUser.search([
|
||||
('iduser.id', '=', book.owner.id),
|
||||
('%s.id' % x, '=', book.id),
|
||||
])
|
||||
if len(cfg1) > 0:
|
||||
to_write_config.extend([ cfg1, {x: None} ])
|
||||
super(Book, cls).write(*args)
|
||||
|
||||
if len(to_write_config) > 0:
|
||||
ConfigUser.write(*to_write_config)
|
||||
|
||||
@classmethod
|
||||
def delete(cls, books):
|
||||
""" deny delete if book has lines
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue