Set readonly state conditional.

This commit refs #2600
This commit is contained in:
Sergio Morillo 2017-06-26 12:46:21 +02:00
parent 640d7cf504
commit 0735a349f7
1 changed files with 8 additions and 0 deletions

View File

@ -24,6 +24,14 @@ class ProductiveProcDocMixin(object):
productive_process = fields.Many2One('productive.process',
'Productive process', ondelete='RESTRICT', required=True, select=True)
@classmethod
def __setup__(cls):
super(ProductiveProcDocMixin, cls).__setup__()
if getattr(cls, 'state', None):
cls.productive_process.states['readonly'] = (
Eval('state') != 'draft')
cls.productive_process.depends.append('state')
@staticmethod
def default_productive_process():
transaction = Transaction()