This question has been flagged

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