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

[unsolved] How to setup Automated Actions to create new Stage and Task when a new Project is created.


This question was answered yesterday and being marked Solved, unfortunately, it's not solved.


When a new project is created based on a template project via a Service Product, it creates a new project based on an existing template, but it also it's still sharing the same Analytic Account as the template, which is just not how it should be when we need a unique analytic account for each project.  Furthermore,  we need project for more than just recording services.


Therefore, can anyone please help me on how to setup automated actions to create new stages & tasks whenever a new project is created?


Thank you. 


I feel the template function used to be in v8 was all we needed, but for some obvious reasons the developers decided to remove it.

Avatar
Discard

Rather than an automated action to create a new stage/task, would it work for your flow to instead have an automated action that writes a new analytic account for the project?

Author

Dear Lucas,


Unfortunately, the duplicated project based on a template also duplicates the Stage & Tasks, but the Stage are shared between the duplicated project and the template project.

What we need to do is to have the new project have the same stage & tasks names as the template project, but are unique, not linked to the template.

Best Answer

Steps to Set up Automated Actions for Creating Stage and Task:

  1. Navigate to Automated Actions: Log in to your Odoo instance and go to the Settings menu. Scroll down to the Technical section and click on Automation -> Automated Actions.
  2. Create a New Action: Click on the "Create" button.
  3. Configure Action Settings:
    • Model: Choose Project from the list, which corresponds to project.project.
    • Trigger Condition: Select "On Creation" from the dropdown.
    • Action To Do: Select "Execute Python Code".
  4. Write Python Code: You will see a Python code box where you can write Python code to execute. Below is a sample code to create a new stage and task when a new project is created.
# Create a new stage related to the new project
stage = env['project.task.type'].create({
    'name': 'New Custom Stage',
    'project_ids': [(4, record.id)],
})

# Create a new task related to the new project
task = env['project.task'].create({
    'name': 'New Custom Task',
    'project_id': record.id,
    'stage_id': stage.id,
})
  1. Save and Test: After entering the code, save the Automated Action. To test it, create a new project. Upon its creation, a new Stage and Task should be automatically linked to it.

Explanation:

  • env['project.task.type'].create() is used to create a new stage.
  • env['project.task'].create() is used to create a new task.
  • The project_ids and project_id fields are used to relate the stage and task to the new project.

That's it! This is how you can set up an Automated Action in Odoo to create a new Stage and Task whenever a new Project is created.


Avatar
Discard
Author

Wow, thank you!!! Your reply is by far the most accurate and well structured, especially for ppl like me who's not an IT person and have so little understanding to coding.

Thank you heaps!!!

Hi there, is there any way to apply this to specific products? Say I want a stage to be named for one project, but I also want to that stage to have a different name when making a new project.

Related Posts Replies Views Activity
0
Sep 24
710
0
May 24
26
1
Apr 24
3972
0
Mar 24
1066
0
Mar 24
1236