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

In Odoo v15 there is the introduction of Personal Stages to display on My Tasks.

Therefore 'group_by': 'stage_id' is used to display Project Tasks, and 'group_by': 'personal_stage_type_ids' is used to display My Tasks.

I have it setup that the stages are the same for all Users Personal Stages and Project Stages:
Backlog, Next Week, This Week, In Progress, Paused, Held Up, Done

The field personal_stage_type_id in project.task displays only the current Personal Stage of the active user.
I created a one2many field (x_studio_personal_stage) to display the personal stages of each user within user_ids

I’m trying to create to Automated Actions:
       1) If stage_id is modified, update the value of the Personal Stages linked to that Task
       2) If a Personal Stage is modified , update the stage_id

My first attempt for 1) was:
       record['stage_id'] = record.personal_stage_type_id

And my attemp for 2) was:
       for record in records:
              for stage in record.x_studio_personal_stage:
                     stage['stage_id'] = record.stage_id

This is not working. Even if it is updating the values, they are not the correct values. I realized that I have to search by the ID field

I tried for 2) this code:

       for stage in record.x_studio_personal_stage:
              id = self.env['project.task.stage.personal'].sudo().search([(('stage_id.name', '=', stage.stage_id.name),('user_id.name', '=', stage.user_id.name)], limit=1).id
              if id: stage['stage_id'] = id

and this one:
       for stage in record.x_studio_personal_stage:
              id = record.personal_stage_type_id.search([('name', '=', stage.stage_id.display_name),('user_id.name', '=', stage.user_id.name)], limit=1).id
              if id: stage['stage_id'] = id

And many other combinations, but I’m not able to get it working.
I would appreciate if I could get some guidance.?


Avatar
Discard
Author Best Answer

I got it working. I created two Automated Actions.

1st one:

Model:   Task
Trigger On Creation & Update
Trigger Fields: Stage; Assignees
Action To Do Execute Python Code

for record in records:
    for stage in record.x_personal_stages:
        project_task_type = env['project.task.type'].search([('name', '=', record.stage_id.name),('user_id.name', '=', stage.user_id.name)], limit=1)
        if project_task_type: stage['stage_id'] = project_task_type


2nd one:
Model:   Task
Trigger On Creation & Update
Trigger Fields: Personal User Stage
Action To Do Execute Python Code


project_task_type = env['project.task.type'].search([('name', '=', record.personal_stage_type_id.display_name),('user_id', '=', False)], limit=1)
if project_task_type: record['stage_id'] = project_task_type

Avatar
Discard
Related Posts Replies Views Activity
0
Jan 22
826
0
Jan 22
1330
1
Jun 22
1291
1
Jun 22
576
1
Apr 24
381