-
-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] project_parent_task_filter: Migration to 15.0
- Loading branch information
1 parent
79252d3
commit 74af397
Showing
5 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from . import models | ||
|
||
from odoo import api, SUPERUSER_ID | ||
|
||
|
||
def _add_task_display_project(cr, registry): | ||
"""This hook is used to set display_project_id field to the tasks that have a project_id set | ||
but empty display_project_id. | ||
This makes subtasks created in the Sub-task page of the parent Task visible in the project | ||
kanban view""" | ||
|
||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
tasks = env["project.task"].search( | ||
[("parent_id", "!=", False), ("display_project_id", "=", False)] | ||
) | ||
for task in tasks: | ||
task.write({"display_project_id": task.parent_id.project_id.id}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from odoo import api, models | ||
|
||
|
||
class TaskSub(models.Model): | ||
_inherit = "project.task" | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
res = super(TaskSub, self).create(vals_list) | ||
for vals in vals_list: | ||
if vals.get("parent_id", False): | ||
res["display_project_id"] = ( | ||
self.env["project.task"].browse(vals.get("parent_id")).project_id.id | ||
) | ||
return res | ||
|
||
def action_subtask(self): | ||
action = { | ||
"type": "ir.actions.act_window", | ||
"name": "Subtasks of " + self.name, | ||
"res_model": "project.task", | ||
"view_mode": "tree,kanban,form,calendar,pivot,graph,activity", | ||
"search_view_id": [ | ||
self.env.ref("project.view_task_search_form").id, | ||
"search", | ||
], | ||
"domain": [("id", "!=", self.id), ("id", "child_of", self.id)], | ||
} | ||
return action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters