diff --git a/book.py b/book.py
index 38fa020..fde854d 100644
--- a/book.py
+++ b/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
diff --git a/configuration.py b/configuration.py
index 2dc986e..0566a64 100644
--- a/configuration.py
+++ b/configuration.py
@@ -15,10 +15,6 @@ field_done = fields.Boolean(string='Done',
help='Show cashbook lines in Done-state.')
field_catnamelong = fields.Boolean(string='Category: Show long name',
help='Shows the long name of the category in the Category field of a cash book line.')
-field_defbook = fields.Many2One(string='Default Cashbook',
- help='The default cashbook is selected when you open the booking wizard.',
- model_name='cashbook.book', ondelete='SET NULL',
- domain=[('btype', '!=', None)])
class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
@@ -40,7 +36,42 @@ class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
checked = fields.MultiValue(field_checked)
done = fields.MultiValue(field_done)
catnamelong = fields.MultiValue(field_catnamelong)
- defbook = fields.MultiValue(field_defbook)
+ defbook = fields.MultiValue(fields.Many2One(string='Default Cashbook',
+ help='The default cashbook is selected when you open the booking wizard.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None), ('state', '=', 'open'),
+ ]))
+ book1 = fields.MultiValue(fields.Many2One(string='Cashbook 1',
+ help='Cash book available in selection dialog.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None), ('state', '=', 'open'),
+ ]))
+ book2 = fields.MultiValue(fields.Many2One(string='Cashbook 2',
+ help='Cash book available in selection dialog.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None), ('state', '=', 'open'),
+ ]))
+ book3 = fields.MultiValue(fields.Many2One(string='Cashbook 3',
+ help='Cash book available in selection dialog.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None), ('state', '=', 'open'),
+ ]))
+ book4 = fields.MultiValue(fields.Many2One(string='Cashbook 4',
+ help='Cash book available in selection dialog.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None), ('state', '=', 'open'),
+ ]))
+ book5 = fields.MultiValue(fields.Many2One(string='Cashbook 5',
+ help='Cash book available in selection dialog.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None), ('state', '=', 'open'),
+ ]))
@classmethod
def multivalue_model(cls, field):
@@ -49,7 +80,8 @@ class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
pool = Pool()
if field in ['date_from', 'date_to', 'checked', 'done',
- 'catnamelong', 'defbook']:
+ 'catnamelong', 'defbook', 'book1', 'book2',
+ 'book3', 'book4', 'book5']:
return pool.get('cashbook.configuration_user')
return super(Configuration, cls).multivalue_model(field)
@@ -87,7 +119,54 @@ class UserConfiguration(ModelSQL, UserValueMixin):
checked = field_checked
done = field_done
catnamelong = field_catnamelong
- defbook = field_defbook
+ defbook = fields.Many2One(string='Default Cashbook',
+ help='The default cashbook is selected when you open the booking wizard.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None),
+ ('state', '=', 'open'),
+ ('owner.id', '=', Eval('iduser', -1))
+ ], depends=['iduser'])
+ book1 = fields.Many2One(string='Cashbook 1',
+ help='Cash book available in selection dialog.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None),
+ ('state', '=', 'open'),
+ ('owner.id', '=', Eval('iduser', -1))
+ ], depends=['iduser'])
+ book2 = fields.Many2One(string='Cashbook 2',
+ help='Cash book available in selection dialog.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None),
+ ('state', '=', 'open'),
+ ('owner.id', '=', Eval('iduser', -1))
+ ], depends=['iduser'])
+ book3 = fields.Many2One(string='Cashbook 3',
+ help='Cash book available in selection dialog.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None),
+ ('state', '=', 'open'),
+ ('owner.id', '=', Eval('iduser', -1))
+ ], depends=['iduser'])
+ book4 = fields.Many2One(string='Cashbook 4',
+ help='Cash book available in selection dialog.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None),
+ ('state', '=', 'open'),
+ ('owner.id', '=', Eval('iduser', -1))
+ ], depends=['iduser'])
+ book5 = fields.Many2One(string='Cashbook 5',
+ help='Cash book available in selection dialog.',
+ model_name='cashbook.book', ondelete='SET NULL',
+ domain=[
+ ('btype', '!=', None),
+ ('state', '=', 'open'),
+ ('owner.id', '=', Eval('iduser', -1))
+ ], depends=['iduser'])
@classmethod
def default_checked(cls):
diff --git a/locale/de.po b/locale/de.po
index ba68660..ab6761f 100644
--- a/locale/de.po
+++ b/locale/de.po
@@ -1090,6 +1090,46 @@ msgctxt "help:cashbook.configuration,defbook:"
msgid "The default cashbook is selected when you open the booking wizard."
msgstr "Das Standardkassenbuch wird beim Öffnen des Buchungswizards ausgewählt."
+msgctxt "field:cashbook.configuration,book1:"
+msgid "Cashbook 1"
+msgstr "Kassenbuch 1"
+
+msgctxt "help:cashbook.configuration,book1:"
+msgid "Cash book available in selection dialog."
+msgstr "in Auswahldialog verfügbares Kassenbuch."
+
+msgctxt "field:cashbook.configuration,book2:"
+msgid "Cashbook 2"
+msgstr "Kassenbuch 2"
+
+msgctxt "help:cashbook.configuration,book2:"
+msgid "Cash book available in selection dialog."
+msgstr "in Auswahldialog verfügbares Kassenbuch."
+
+msgctxt "field:cashbook.configuration,book3:"
+msgid "Cashbook 3"
+msgstr "Kassenbuch 3"
+
+msgctxt "help:cashbook.configuration,book3:"
+msgid "Cash book available in selection dialog."
+msgstr "in Auswahldialog verfügbares Kassenbuch."
+
+msgctxt "field:cashbook.configuration,book4:"
+msgid "Cashbook 4"
+msgstr "Kassenbuch 4"
+
+msgctxt "help:cashbook.configuration,book4:"
+msgid "Cash book available in selection dialog."
+msgstr "in Auswahldialog verfügbares Kassenbuch."
+
+msgctxt "field:cashbook.configuration,book5:"
+msgid "Cashbook 5"
+msgstr "Kassenbuch 5"
+
+msgctxt "help:cashbook.configuration,book5:"
+msgid "Cash book available in selection dialog."
+msgstr "in Auswahldialog verfügbares Kassenbuch."
+
msgctxt "field:cashbook.configuration,date_from:"
msgid "Start Date"
msgstr "Beginndatum"
@@ -1170,6 +1210,46 @@ msgctxt "help:cashbook.configuration_user,defbook:"
msgid "The default cashbook is selected when you open the booking wizard."
msgstr "Das Standardkassenbuch wird beim Öffnen des Buchungswizards ausgewählt."
+msgctxt "field:cashbook.configuration_user,book1:"
+msgid "Cashbook 1"
+msgstr "Kassenbuch 1"
+
+msgctxt "help:cashbook.configuration_user,book1:"
+msgid "Cash book available in selection dialog."
+msgstr "in Auswahldialog verfügbares Kassenbuch."
+
+msgctxt "field:cashbook.configuration_user,book2:"
+msgid "Cashbook 2"
+msgstr "Kassenbuch 2"
+
+msgctxt "help:cashbook.configuration_user,book2:"
+msgid "Cash book available in selection dialog."
+msgstr "in Auswahldialog verfügbares Kassenbuch."
+
+msgctxt "field:cashbook.configuration_user,book3:"
+msgid "Cashbook 3"
+msgstr "Kassenbuch 3"
+
+msgctxt "help:cashbook.configuration_user,book3:"
+msgid "Cash book available in selection dialog."
+msgstr "in Auswahldialog verfügbares Kassenbuch."
+
+msgctxt "field:cashbook.configuration_user,book4:"
+msgid "Cashbook 4"
+msgstr "Kassenbuch 4"
+
+msgctxt "help:cashbook.configuration_user,book4:"
+msgid "Cash book available in selection dialog."
+msgstr "in Auswahldialog verfügbares Kassenbuch."
+
+msgctxt "field:cashbook.configuration_user,book5:"
+msgid "Cashbook 5"
+msgstr "Kassenbuch 5"
+
+msgctxt "help:cashbook.configuration_user,book5:"
+msgid "Cash book available in selection dialog."
+msgstr "in Auswahldialog verfügbares Kassenbuch."
+
##################
# cashbook.recon #
diff --git a/locale/en.po b/locale/en.po
index 5d58001..338f7cf 100644
--- a/locale/en.po
+++ b/locale/en.po
@@ -1022,6 +1022,46 @@ msgctxt "help:cashbook.configuration,defbook:"
msgid "The default cashbook is selected when you open the booking wizard."
msgstr "The default cashbook is selected when you open the booking wizard."
+msgctxt "field:cashbook.configuration,book1:"
+msgid "Cashbook 1"
+msgstr "Cashbook 1"
+
+msgctxt "help:cashbook.configuration,book1:"
+msgid "Cash book available in selection dialog."
+msgstr "Cash book available in selection dialog."
+
+msgctxt "field:cashbook.configuration,book2:"
+msgid "Cashbook 2"
+msgstr "Cashbook 2"
+
+msgctxt "help:cashbook.configuration,book2:"
+msgid "Cash book available in selection dialog."
+msgstr "Cash book available in selection dialog."
+
+msgctxt "field:cashbook.configuration,book3:"
+msgid "Cashbook 3"
+msgstr "Cashbook 3"
+
+msgctxt "help:cashbook.configuration,book3:"
+msgid "Cash book available in selection dialog."
+msgstr "Cash book available in selection dialog."
+
+msgctxt "field:cashbook.configuration,book4:"
+msgid "Cashbook 4"
+msgstr "Cashbook 4"
+
+msgctxt "help:cashbook.configuration,book4:"
+msgid "Cash book available in selection dialog."
+msgstr "Cash book available in selection dialog."
+
+msgctxt "field:cashbook.configuration,book5:"
+msgid "Cashbook 5"
+msgstr "Cashbook 5"
+
+msgctxt "help:cashbook.configuration,book5:"
+msgid "Cash book available in selection dialog."
+msgstr "Cash book available in selection dialog."
+
msgctxt "field:cashbook.configuration,date_from:"
msgid "Start Date"
msgstr "Start Date"
@@ -1098,6 +1138,46 @@ msgctxt "help:cashbook.configuration_user,defbook:"
msgid "The default cashbook is selected when you open the booking wizard."
msgstr "The default cashbook is selected when you open the booking wizard."
+msgctxt "field:cashbook.configuration_user,book1:"
+msgid "Cashbook 1"
+msgstr "Cashbook 1"
+
+msgctxt "help:cashbook.configuration_user,book1:"
+msgid "Cash book available in selection dialog."
+msgstr "Cash book available in selection dialog."
+
+msgctxt "field:cashbook.configuration_user,book2:"
+msgid "Cashbook 2"
+msgstr "Cashbook 2"
+
+msgctxt "help:cashbook.configuration_user,book2:"
+msgid "Cash book available in selection dialog."
+msgstr "Cash book available in selection dialog."
+
+msgctxt "field:cashbook.configuration_user,book3:"
+msgid "Cashbook 3"
+msgstr "Cashbook 3"
+
+msgctxt "help:cashbook.configuration_user,book3:"
+msgid "Cash book available in selection dialog."
+msgstr "Cash book available in selection dialog."
+
+msgctxt "field:cashbook.configuration_user,book4:"
+msgid "Cashbook 4"
+msgstr "Cashbook 4"
+
+msgctxt "help:cashbook.configuration_user,book4:"
+msgid "Cash book available in selection dialog."
+msgstr "Cash book available in selection dialog."
+
+msgctxt "field:cashbook.configuration_user,book5:"
+msgid "Cashbook 5"
+msgstr "Cashbook 5"
+
+msgctxt "help:cashbook.configuration_user,book5:"
+msgid "Cash book available in selection dialog."
+msgstr "Cash book available in selection dialog."
+
msgctxt "model:cashbook.recon,name:"
msgid "Cashbook Reconciliation"
msgstr "Cashbook Reconciliation"
diff --git a/view/configuration_form.xml b/view/configuration_form.xml
index 36c5e77..aa870e4 100644
--- a/view/configuration_form.xml
+++ b/view/configuration_form.xml
@@ -15,6 +15,18 @@ this repository contains the full copyright notices and license terms. -->
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/wizard_booking.py b/wizard_booking.py
index 4a383d1..27304c9 100644
--- a/wizard_booking.py
+++ b/wizard_booking.py
@@ -134,11 +134,17 @@ class EnterBookingWizard(Wizard):
cfg1 = Configuration.get_singleton()
+ book_ids = []
+ for x in ['defbook', 'book1', 'book2', 'book3', 'book4', 'book5']:
+ if getattr(cfg1, x, None) is not None:
+ book_ids.append(getattr(cfg1, x, None).id)
+
result = {
'cashbooks': [x.id for x in Cashbook.search([
('state', '=', 'open'),
('btype', '!=', None),
('owner.id', '=', Transaction().user),
+ ('id', 'in', book_ids),
])],
'bookingtype': getattr(self.start, 'bookingtype', 'out'),
'cashbook': getattr(getattr(cfg1, 'defbook', None), 'id', None),