[IMP]project_assignees:add project manager as default assignee
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
from odoo import models, fields
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
|
||||||
class Task(models.Model):
|
class Task(models.Model):
|
||||||
@@ -7,3 +7,14 @@ class Task(models.Model):
|
|||||||
|
|
||||||
assignee_ids = fields.Many2many('res.users', 'assignee_ids_rel', string='Assignees', tracking=True)
|
assignee_ids = fields.Many2many('res.users', 'assignee_ids_rel', string='Assignees', tracking=True)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def create(self, vals):
|
||||||
|
'''
|
||||||
|
assigned project manager to the task if nobody else is assigned to
|
||||||
|
'''
|
||||||
|
assignee_ids = vals.get('assignee_ids', [])
|
||||||
|
project_id = vals.get('project_id', [])
|
||||||
|
if project_id and assignee_ids and not assignee_ids[0][2]:
|
||||||
|
project = self.env['project.project'].browse(project_id)
|
||||||
|
assignee_ids[0][2] = str(project.user_id.id)
|
||||||
|
return super().create(vals)
|
Reference in New Issue
Block a user