Skip to content

Commit

Permalink
[REM] project_task_subtask: удалили плохо-понимаемые представления в …
Browse files Browse the repository at this point in the history
…канбане
  • Loading branch information
em230418 committed Dec 27, 2024
1 parent 8b361b2 commit 1f013cd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 81 deletions.
72 changes: 0 additions & 72 deletions project_task_subtask/models/project_task_subtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ 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.Text(compute="_compute_kanban_subtasks")
default_user = fields.Many2one("res.users", compute="_compute_default_user")
completion = fields.Integer(compute="_compute_completion")
completion_xml = fields.Text(compute="_compute_completion_xml")

def _compute_default_user(self):
for record in self:
Expand All @@ -154,75 +151,6 @@ def _compute_default_user(self):
else:
record.default_user = False

def _compute_kanban_subtasks(self):
for record in self:
result_string_td = ""
result_string_wt = ""
if record.subtask_ids:
task_todo_ids = record.subtask_ids.filtered(
lambda x: x.state == "todo" and x.user_id.id == record.env.user.id
)
task_waiting_ids = record.subtask_ids.filtered(
lambda x: x.state == "waiting"
and x.user_id.id == record.env.user.id
)
if task_todo_ids:
tmp_string_td = escape(": {}".format(len(task_todo_ids)))
result_string_td += "<li><b>TODO{}</b></li>".format(tmp_string_td)
if task_waiting_ids:
tmp_string_wt = escape(": {}".format(len(task_waiting_ids)))
result_string_wt += "<li><b>Waiting{}</b></li>".format(
tmp_string_wt
)
record.kanban_subtasks = (
'<div class="kanban_subtasks"><ul>'
+ result_string_td
+ result_string_wt
+ "</ul></div>"
)

def _compute_completion(self):
for record in self:
record.completion = record.task_completion()

def _compute_completion_xml(self):
for record in self:
active_subtasks = record.subtask_ids and record.subtask_ids.filtered(
lambda x: x.user_id.id == record.env.user.id and x.state != "cancelled"
)
if not active_subtasks:
record.completion_xml = """
<div class="task_progress">
</div>
"""
continue

completion = record.task_completion()
color = "bg-success-full"
if completion < 50:
color = "bg-danger-full"
record.completion_xml = """
<div class="task_progress">
<div class="progress_info">
Your Checklist:
</div>
<div class ="o_kanban_counter_progress progress task_progress_bar">
<div data-filter="done"
class ="progress-bar {1} o_bar_has_records task_progress_bar_done"
data-original-title="1 done"
style="width: {0}%;">
</div>
<div data-filter="blocked"
class ="progress-bar bg-danger-full"
data-original-title="0 blocked">
</div>
</div>
<div class="task_completion"> {0}% </div>
</div>
""".format(
int(completion), color
)

def task_completion(self):
user_task_ids = self.subtask_ids.filtered(
lambda x: x.user_id.id == self.env.user.id and x.state != "cancelled"
Expand Down
9 changes: 0 additions & 9 deletions project_task_subtask/views/project_task_subtask.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,7 @@
<field name="inherit_id" ref="project.view_task_kanban" />
<field name="arch" type="xml">
<xpath expr="//field[@name ='tag_ids']" position="after">
<field name="completion" invisible="1" />
<field name="subtask_ids" invisible="1" />
<field name="kanban_subtasks" invisible="1" />
<field name="completion_xml" invisible="1" />
</xpath>
<xpath expr="//div[hasclass('o_kanban_record_bottom')]" position="before">
<div>
<t t-raw="record.completion_xml.raw_value" />
<t t-raw="record.kanban_subtasks.raw_value" />
</div>
</xpath>
</field>
</record>
Expand Down

0 comments on commit 1f013cd

Please sign in to comment.