콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
3686 화면

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!

아바타
취소
베스트 답변

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

아바타
취소
작성자

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!

작성자

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?

작성자

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

베스트 답변

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

아바타
취소
관련 게시물 답글 화면 활동
2
3월 23
1852
2
7월 24
7267
1
3월 15
3416
1
3월 15
6980
2
3월 25
1141