Odoo Help

0

0
1 Answer
0
Samo Arko
11.04.19, 03:11

This just can't be done with the write method. Had to disable moving  the task to certain stages with the @api.constrain('stage_id'). And allow to move to them only with a button. The button then executes a query.

self.env.cr.execute('UPDATE project_task '
                    'SET stage_id = %(stage_id)s, locked = TRUE, write_date = %(write_date)s '
                    'WHERE id IN %(task_id)s ', ({'stage_id': stage_id, 'task_id': tuple(task_ids), 'write_date': write_timestamp}))

After that I just check the locked field in the write method

if self.locked:
	raise ValidationError(_(u'Task cannot be changed!'))
Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now