Skip to content

Commit

Permalink
[MIG] project_task_subtask: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
em230418 committed Dec 28, 2024
1 parent 0598a0f commit b6eefed
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion project_task_subtask/demo/project_task_subtask_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<record id="project_task_subtask_1" model="project.task.subtask">
<field name="name">test subtask</field>
<field name="user_id" eval="ref('base.user_demo')" />
<field name="task_id" eval="ref('project.project_task_1')" />
<field name="task_id" eval="ref('project.project_1_task_9')" />
</record>
</odoo>
51 changes: 26 additions & 25 deletions project_task_subtask/models/project_task_subtask.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from markupsafe import Markup, escape

from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.tools import html_escape
from odoo.tools.translate import _

SUBTASK_STATES = {
Expand All @@ -11,10 +12,6 @@
}


def escape(s):
return str(html_escape(s))


class ProjectTaskSubtask(models.Model):
_name = "project.task.subtask"
_description = "Subtask"
Expand All @@ -35,7 +32,7 @@ class ProjectTaskSubtask(models.Model):
)
user_id = fields.Many2one("res.users", "Assigned to", required=True)
task_id = fields.Many2one(
"project.task", "Task", ondelete="cascade", required=True, index="1"
"project.task", "Task", ondelete="cascade", required=True, index=True
)
task_state = fields.Char(
string="Task state", related="task_id.stage_id.name", readonly=True
Expand Down Expand Up @@ -183,52 +180,56 @@ def send_subtask_email(
state = '<span style="color:#b818ce">' + state + "</span>"
partner_ids = []
if user == self.env.user and reviewer == self.env.user:
body = "<p>" + "<strong>" + state + "</strong>: " + escape(subtask_name)
body = Markup("<p><strong>" + state + "</strong>: ") + escape(
subtask_name
)
elif self.env.user == reviewer:
body = (
"<p>"
Markup("<p>")
+ escape(user.name)
+ ", <br><strong>"
+ state
+ "</strong>: "
+ Markup(", <br><strong>")
+ Markup(state)
+ Markup("</strong>: ")
+ escape(subtask_name)
)
partner_ids = [user.partner_id.id]
elif self.env.user == user:
body = (
"<p>"
Markup("<p>")
+ escape(reviewer.name)
+ ', <em style="color:#999">I updated checklist item assigned to me:</em> <br><strong>' # noqa: B950
+ state
+ "</strong>: "
+ ", "
+ Markup(
'<em style="color:#999">I updated checklist item assigned to me:</em> <br><strong>' # noqa: B950
)
+ Markup(state + "</strong>: ")
+ escape(subtask_name)
)
partner_ids = [reviewer.partner_id.id]
else:
body = (
"<p>"
Markup("<p>")
+ escape(user.name)
+ ", "
+ escape(reviewer.name)
+ ', <em style="color:#999">I updated checklist item, now its assigned to '
+ Markup(
', <em style="color:#999">I updated checklist item, now its assigned to ' # noqa: B950
)
+ escape(user.name)
+ ": </em> <br><strong>"
+ state
+ "</strong>: "
+ Markup(": </em> <br><strong>")
+ Markup(state + "</strong>: ")
+ escape(subtask_name)
)
partner_ids = [user.partner_id.id, reviewer.partner_id.id]
if old_name:
body = (
body
+ '<br><em style="color:#999">Updated from</em><br><strong>'
+ state
+ "</strong>: "
+ Markup('<br><em style="color:#999">Updated from</em><br><strong>')
+ Markup(state + "</strong>: ")
+ escape(old_name)
+ "</p>"
+ Markup("</p>")
)
else:
body = body + "</p>"
body = body + Markup("</p>")
r.message_post(
message_type="comment",
body=body,
Expand Down
8 changes: 4 additions & 4 deletions project_task_subtask/views/project_task_subtask.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@
title="Change state to DONE"
type="object"
icon="fa-check"
attrs="{'invisible': ['|', ('state', 'in',['done', 'cancelled']), ('hide_button', '=', True)]}"
invisible="state in ['done', 'cancelled'] or hide_button == True"
/>
<button
name="change_state_todo"
title="Change state to TODO"
type="object"
icon="fa-caret-square-o-right"
attrs="{'invisible': [ '|',('state', '=', 'todo'), ('hide_button', '=', True)]}"
invisible="state == 'todo' or hide_button == True"
/>
<button
name="change_state_waiting"
type="object"
title="Change state to Waiting"
icon="fa-pause"
attrs="{'invisible': [ '|',('state', '=', 'waiting'), ('hide_button', '=', True)]}"
invisible="state == 'waiting' or hide_button == True"
/>
<button
name="change_state_cancelled"
type="object"
title="Change state to CANCELLED"
icon="fa-ban"
attrs="{'invisible': [ '|',('state', '=', 'cancelled'), ('hide_button', '=', True)]}"
invisible="state == 'cancelled' or hide_button == True"
/>
<field name="reviewer_id" />
<field name="deadline" />
Expand Down

0 comments on commit b6eefed

Please sign in to comment.