book/line: berechtigungen für owner, beobachter, bearbeiter + tests
This commit is contained in:
parent
654e9d2ee7
commit
b9bb433c39
9 changed files with 584 additions and 3 deletions
15
book.py
15
book.py
|
@ -7,6 +7,7 @@ from trytond.model import Workflow, ModelView, ModelSQL, fields, Check
|
|||
from trytond.pyson import Eval
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
STATES = {
|
||||
|
@ -30,6 +31,14 @@ class Book(Workflow, ModelSQL, ModelView):
|
|||
btype = fields.Many2One(string='Type', required=True,
|
||||
model_name='cashbook.type', ondelete='RESTRICT',
|
||||
states=STATES, depends=DEPENDS)
|
||||
owner = fields.Many2One(string='Owner', required=True, select=True,
|
||||
model_name='res.user', ondelete='SET NULL')
|
||||
reviewer = fields.Many2One(string='Reviewer', select=True,
|
||||
help='Group of users who have write access to the cashbook.',
|
||||
model_name='res.group', ondelete='SET NULL')
|
||||
observer = fields.Many2One(string='Observer', select=True,
|
||||
help='Group of users who have read-only access to the cashbook.',
|
||||
model_name='res.group', ondelete='SET NULL')
|
||||
lines = fields.One2Many(string='Lines', field='cashbook',
|
||||
model_name='cashbook.line',
|
||||
states=STATES, depends=DEPENDS)
|
||||
|
@ -71,6 +80,12 @@ class Book(Workflow, ModelSQL, ModelView):
|
|||
def default_state(cls):
|
||||
return 'open'
|
||||
|
||||
@classmethod
|
||||
def default_owner(cls):
|
||||
""" default: current user
|
||||
"""
|
||||
return Transaction().user
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('open')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue