跳至内容
菜单
此问题已终结
1 回复
1543 查看

I want to add the project_id to tasks of a project:


all_projects = request.env['project.project'].search([])
for project in all_projects: 
    for task in project.tasks: 
        task.project_id = project.id

Thank you for any suggestions
形象
丢弃
最佳答案

Hi,

If you have a lot of tasks in the database, how will you distinguish the tasks that you have to update ? is it something like, changing existing project to an another project ?

so first you have to decide it and add it in the below domain ?

domain = []

tasks = self.env['project.task'].search(domain)

for task in tasks:

    task.project_id = ID_OF_THE_NEW_PROJECT


Thanks

形象
丢弃
编写者

Hi,

the projects already contain the tasks in project.task_ids.
Now I need to show the project in the task.project_id

Thank you

编写者

Hi Niyas,
I solved it. Had to set display_name for the project.
Thank you

相关帖文 回复 查看 活动
3
9月 25
3398
0
8月 25
906
1
8月 25
3171
2
7月 25
8790
2
7月 25
5146