Skip to content

Commit

Permalink
Add milestone support and clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienbeau committed Oct 29, 2024
1 parent d6e8f70 commit cb6ce42
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 14 deletions.
1 change: 1 addition & 0 deletions project_api/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"project_task_default_stage",
"project_tag",
"project_estimate_step",
"project_milestone",
],
"data": ["views/project_view.xml", "views/partner_view.xml"],
"demo": ["demo/partner_demo.xml", "demo/project_demo.xml"],
Expand Down
10 changes: 10 additions & 0 deletions project_api/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def _get_customer_project_name(self):
class ProjectTask(models.Model):
_inherit = "project.task"

milestone_name = fields.Char(
compute="_compute_milestone_name",
store=True,
)
stage_name = fields.Char(
"Stage Label",
compute="_compute_stage_name",
Expand Down Expand Up @@ -110,6 +114,12 @@ def _compute_stage_name(self):
for task in self:
task.stage_name = task.stage_id.name

@api.depends("milestone_id.name")
def _compute_milestone_name(self):
for task in self:
task.milestone_name =\
f"{task.milestone_id.target_date} - {task.milestone_id.name}"

def _inverse_stage_name(self):
for task in self:
stages = self.env["project.task.type"].search(
Expand Down
7 changes: 6 additions & 1 deletion project_api/services/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ def config(self):
"id": project.id,
"name": project.name,
"tags": [{"id": tag.id, "name": tag.name, "color": tag.color} for tag in project.tag_ids],
"stages": [{"id": st.id, "name": st.name, "sequence": st.sequence} for st in project.type_ids],
"stages": [{
"id": st.id,
"name": st.name,
"sequence": st.sequence,
"fold": st.fold,
} for st in project.type_ids],
})
return config

Expand Down
6 changes: 3 additions & 3 deletions project_api_client/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ msgid "Datas Fname"
msgstr ""

#. module: project_api_client
#: model:ir.model.fields,field_description:project_api_client.field_external_task__date_deadline
msgid "Date deadline"
msgstr "Date deadline"
#: model:ir.model.fields,field_description:project_api_client.field_external_task__date_end
msgid "Date de fin"
msgstr "Date de fin"

#. module: project_api_client
#: model_terms:ir.ui.view,arch_db:project_api_client.view_external_task_kanban
Expand Down
4 changes: 2 additions & 2 deletions project_api_client/i18n/project_api_client.pot
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ msgid "Datas Fname"
msgstr ""

#. module: project_api_client
#: model:ir.model.fields,field_description:project_api_client.field_external_task__date_deadline
msgid "Date deadline"
#: model:ir.model.fields,field_description:project_api_client.field_external_task__date_end
msgid "Date de fin"
msgstr ""

#. module: project_api_client
Expand Down
1 change: 1 addition & 0 deletions project_api_client/models/o2o_project_task_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ class O2OProjectTaskStage(models.Model):
name = fields.Char()
current_sprint = fields.Boolean()
sequence = fields.Integer()
fold = fields.Boolean()
3 changes: 2 additions & 1 deletion project_api_client/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _get_default_project(self):
priority = fields.Selection(
[("0", "Low"), ("1", "Normal"), ("2", "High")], default="1"
)
date_deadline = fields.Date("Date deadline", readonly=True)
date_end = fields.Date("Date de fin", readonly=True)
author_id = fields.Many2one("res.partner", string="Author", readonly=True)
assignee_supplier_id = fields.Many2one(
"res.partner", string="Resp. Externe", readonly=True
Expand Down Expand Up @@ -79,6 +79,7 @@ def _get_default_project(self):
copy=False, default='normal', required=True)
sequence = fields.Integer()
is_closed = fields.Boolean()
milestone_name = fields.Char("Jalon")

@api.model
def _call_odoo(self, method, params):
Expand Down
22 changes: 15 additions & 7 deletions project_api_client/views/project_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@
<field name="priority" />
<field name="planned_days" sum="Total Planned"/>
<field name="invoiceable_days" sum="Total Real"/>
<field name="date_deadline" />
<field name="date_end" />
<field name="milestone_name" />
<field name="create_date" />
</tree>
</field>
Expand All @@ -200,10 +201,10 @@
<filter string="My task" name="my_task" />
<separator />
<filter
string="Current Sprint"
name="current_sprint"
domain="[('stage_id.current_sprint', '=', True)]"
string="Tache en cours"
name="todo_task"
context="{'no_empty_stage': True}"
domain="[('stage_id.fold', '=', False)]"
/>
<separator />
<group expand="0" string="Group By">
Expand All @@ -212,6 +213,11 @@
name="stage"
context="{'group_by': 'stage_id'}"
/>
<filter
string="Jalon"
name="milestone"
context="{'group_by': 'milestone_name'}"
/>
</group>
</search>
</field>
Expand All @@ -225,14 +231,15 @@
<field name="stage_id" />
<field name="color" />
<field name="priority" />
<field name="date_deadline" />
<field name="date_end" />
<field name="assignee_customer_id" />
<field name="assignee_supplier_id" />
<field name="tag_ids" />
<field name="estimate_step_name" />
<field name="invoiceable_days" />
<field name="id" />
<field name="create_date" />
<field name="milestone_name" />
<progressbar field="kanban_state" colors='{"done": "success", "blocked": "danger", "normal": "muted"}'/>
<templates>
<t t-name="kanban-box">
Expand All @@ -249,13 +256,14 @@
class="o_kanban_record_subtitle text-muted"
>
<t
t-if="record.date_deadline.raw_value and record.date_deadline.raw_value lt (new Date())"
t-if="record.date_end.raw_value and record.date_end.raw_value lt (new Date())"
t-set="red"
>oe_kanban_text_red</t>
<span t-attf-class="#{red || ''}"><i><field
name="date_deadline"
name="date_end"
/></i></span>
<span><field name="create_date" /></span>
<span><field name="milestone_name" /></span>
</small>
</div>
<div
Expand Down

0 comments on commit cb6ce42

Please sign in to comment.