diff --git a/project_task_subtask/models/project_task_subtask.py b/project_task_subtask/models/project_task_subtask.py index e599b06..5c7f8d8 100644 --- a/project_task_subtask/models/project_task_subtask.py +++ b/project_task_subtask/models/project_task_subtask.py @@ -1,4 +1,4 @@ -from markupsafe import Markup, escape +from markupsafe import Markup from odoo import api, fields, models from odoo.exceptions import UserError @@ -12,10 +12,6 @@ } -# def escape(s): -# return str(html_escape(s)) - - class ProjectTaskSubtask(models.Model): _name = "project.task.subtask" _description = "Subtask" @@ -47,17 +43,18 @@ class ProjectTaskSubtask(models.Model): def _compute_recolor(self): for record in self: - if self.env.user == record.user_id and record.state == "todo": - record.recolor = True - else: - record.recolor = False + record.recolor = ( + True + if self.env.user == record.user_id and record.state == "todo" + else False + ) def _compute_hide_button(self): for record in self: - if self.env.user not in [record.reviewer_id, record.user_id]: - record.hide_button = True - else: - record.hide_button = False + record.hide_button = self.env.user not in [ + record.reviewer_id, + record.user_id, + ] def _compute_reviewer_id(self): for record in self: @@ -128,7 +125,6 @@ def change_state_waiting(self): class Task(models.Model): _inherit = "project.task" - subtask_ids = fields.One2many("project.task.subtask", "task_id", "Subtask") kanban_subtasks = fields.Html(compute="_compute_kanban_subtasks") default_user = fields.Many2one("res.users", compute="_compute_default_user") @@ -246,88 +242,7 @@ def send_subtask_email( subtask_user_id, old_name=None, ): - for r in self: - body = Markup("") # Initialize body as a Markup object - reviewer = self.env["res.users"].browse(subtask_reviewer_id) - user = self.env["res.users"].browse(subtask_user_id) - state = Markup(SUBTASK_STATES[subtask_state]) # Keep state as Markup - - # Set state color based on subtask state - if subtask_state == "done": - state = Markup('' + str(state) + "") - elif subtask_state == "todo": - state = Markup('' + str(state) + "") - elif subtask_state == "cancelled": - state = Markup('' + str(state) + "") - elif subtask_state == "waiting": - state = Markup('' + str(state) + "") - - partner_ids = [] - - if user == self.env.user and reviewer == self.env.user: - body = Markup( - "

" - + str(state) - + ": " - + escape(subtask_name) - + "

" - ) - elif self.env.user == reviewer: - body = Markup( - "

" - + escape(user.name) - + ",
" - + str(state) - + ": " - + escape(subtask_name) - + "

" - ) - partner_ids = [user.partner_id.id] - elif self.env.user == user: - body = Markup( - "

" + escape(reviewer.name) + ', ' - "I updated checklist item assigned to me:
" - + str(state) - + ": " - + escape(subtask_name) - + "

" - ) - partner_ids = [reviewer.partner_id.id] - else: - body = Markup( - "

" - + escape(user.name) - + ", " - + escape(reviewer.name) - + ', I updated checklist item, now its assigned to ' - + escape(user.name) - + ":
" - + str(state) - + ": " - + escape(subtask_name) - + "

" - ) - partner_ids = [user.partner_id.id, reviewer.partner_id.id] - - if old_name: - body += Markup( - '
Updated from
' - + str(state) - + ": " - + escape(old_name) - + "

" - ) - else: - body += Markup("

") - - r.message_post( - message_type="comment", - body=body, - partner_ids=partner_ids, - ) + state = Markup(SUBTASK_STATES[subtask_state]) - def copy(self, default=None): - task = super(Task, self).copy(default) - for subtask in self.subtask_ids: - subtask.copy({"task_id": task.id, "state": subtask.state}) - return task + if subtask_state == "done": + state = Markup(' - project.task.kanban.subtasks - project.task - - - - - - - - - -
- - -
-
-
- + project.task.kanban.subtasks + project.task + + + + + + + + + +
+ + +
+
+
+ - - project.task.subtask - project.task.subtask - -
- - - - - - - - -
-
-
+ + project.task.subtask + project.task.subtask + +
+ + + + + + + + +
+
+
project.task.subtask.filter