Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
3683 Tampilan

Hello,

We are trying to create an automatic rule that moves the project to a stage, when ALL tasks inside that project reach the mirrored task stage.
(for example: if all project tasks are in stage 2, automatically project will move to stage 2).

we tried creating a studio automatic rule but it doesn't work, could you please tell us what we are doing wrong? 

(V. 16)

Model: Project
trigger: Update
Activation fields: Task (project)
Apply to: Task>Stage = In progress

Action to do: udate record

Field: Task (project)
Type of evaluation: Value
record: In progress
Value: 2


thank you!

Avatar
Buang
Jawaban Terbai

Hello Diego Avila,

You can move project to a stage when all tasks reach that stage using Automated Action.

Find Example in comment.

I hope you are doing well.

For Example -

Note - Check Indentation of the code after pasting the code
- stage_id stores the stage to which you want to move the project

- Create an automated action by adding
name, model( Task (project.task) as per your requirement),
trigger(update as per your requirement), Trigger fields (Stage (project.task) as per your requirement),
, Action To Do ( Execute Python Code )

- Search the Stage you want to move.

- In the Python Code Below Paste this code:-
if len(records.project_id.task_ids.mapped('stage_id.name'))==1:
stage_id = env['project.project.stage'].search([('name','=','In Progress')])
records.project_id.write({"stage_id":stage_id})

I hope this would be helpful.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Buang
Penulis

Hello Jainesh,

Thank you for looking into this! Unfortunately It didn't work, but I am sure it is because I am doing something wrong because I don't know coding or phyton. (I can't send screenshots because I don't have karma, so I will list below what I entered in all fields: ("entrega final" is the name of the stage all tasks are moved to/project consequently needs to be moved to)

Model: Project
trigger: Update
Activation fields: Task stage (project.project)

Before updating the domain: (I didn't touch this field)
Apply to: (I didn't touch this field)

Action to do: execute phyton code

Phyton code:
1.if len(records.project_id.task_ids.mapped('stage_id.name'))==1:
2.   stage_id = env['project.project.stage'].search([('name','=','entrega final')])
3.   records.project_id.write({"stage_id":stage_id})

(I left 3 spaces as "indent" in the second 2 lines)

Thank you very much for all your help!

Penulis

Hello Jainesh,
please disregard my previous comment, I had the Model wrong :(,
We corrected the model and now the code did work in a part: what happens now is that when all tasks are moved to the stage "entrega final" the project is moved to a non-existing stage that is created by the system :/

could you please help us with this?

Penulis

This is the correct answer! The code did work, we were placing it incorrectly. Thank you very much for all your help!

Jawaban Terbai

Hello I want to implement this code with a small upgrade. 

This code work very well if I have to move a project when i have a specific task_ids stage. 
But if i want to make this code dinamically? For example if i have 3 stage_id for task inside a project(stage1, stage2, stage3) and i have 3 stage_id for project. 

I want that when task stage inside project are all to stage2 the relative project move on stage2 and if task stage move all from stage2 to stage3 project does same. 

How to implement this in the pythone code?

Thank you

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Mar 23
1850
2
Jul 24
7264
1
Mar 15
3413
1
Mar 15
6961
2
Mar 25
1133