When a task is created, it automatically updates the subtasks that I want to pre-define.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
When a task is created, it automatically updates the subtasks that I want to pre-define.
Hi,
Please try below code
from odoo import models, fields, api
class ProjectTask(models.Model):
_inherit = 'project.task'
@api.model
def create(self, vals):
task = super().create(vals)
# Only create subtasks if this is NOT a subtask already
if not vals.get('parent_id'):
predefined_subtasks = [
{'name': 'Requirement Gathering'},
{'name': 'Design'},
{'name': 'Development'},
{'name': 'Testing'},
{'name': 'Deployment'},
]
for subtask_data in predefined_subtasks:
self.create({
'name': subtask_data['name'],
'project_id': __manifest__.py
'depends': ['project'],
Second Way
UI-Only (Automated Actions - Odoo Studio)
If you're using Odoo Online (SaaS) or want to do this without code:
Go to: Settings > Technical > Automated Actions
Create a new action:
Add multiple “Create Record” actions with:
i hope it is helpfull
Hi,
Please refer to the code below:
from odoo import models, api
class ProjectTask(models.Model):
_inherit = 'project.task'
@api.model
def create(self, vals):
task = super(ProjectTask, self).create(vals)
# Check if project or any condition needed
if vals.get('project_id'): # Or any project-specific logic
subtasks = ['Design', 'Development', 'Testing'] # sample redefined subtask
for sub in subtasks:
self.create({
'name': sub,
'parent_id': task.id,
'project_id': task.project_id.id,
})
return task
Hope it helps.
Create an account today to enjoy exclusive features and engage with our awesome community!
RegistráciaRelated Posts | Replies | Zobrazenia | Aktivita | |
---|---|---|---|---|
|
2
aug 25
|
168 | ||
|
2
aug 25
|
1309 | ||
|
0
feb 25
|
1450 | ||
|
1
jan 25
|
2011 | ||
|
2
dec 24
|
1681 |