Skip to Content
Menu
This question has been flagged
1 Reply
1400 Views

i want to place constraint on number of task a user can create in te model project limiting it to 5  depending on if te task is done normal or blocked can i have an example of script please .

Avatar
Discard
Author

not workin error

'project.task' object has no attribute 'self'

Override odoo functions: https://goo.gl/4BkizH

Best Answer
override create a method of project.task like

def create(self, vals):
project_id = self.get('project_id')
project = self.env['project.project'].browse(project_id)
if len(project.task_ids) > 6:
raise UserError(_('Not allow to create more than 5 task in project'))
return super(ProjectTask, self).create(vals)
Avatar
Discard