-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
project_workload: add view to see load, automatically set done load w…
…hen the task is closed
- Loading branch information
1 parent
7955d70
commit 1cf7476
Showing
5 changed files
with
100 additions
and
5 deletions.
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
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# @author Florian Mounier <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
from odoo import api, fields, models | ||
|
||
|
||
class ProjectWorkloadUnit(models.Model): | ||
|
@@ -18,8 +18,21 @@ class ProjectWorkloadUnit(models.Model): | |
) | ||
task_id = fields.Many2one("project.task", "Task", related="workload_id.task_id") | ||
project_id = fields.Many2one( | ||
"project.project", "Project", related="workload_id.project_id" | ||
"project.project", | ||
"Project", | ||
related="workload_id.project_id", | ||
store=True, | ||
) | ||
done = fields.Boolean(compute="_compute_done", store=True) | ||
|
||
def is_done(self): | ||
self.ensure_one() | ||
return self.task_id.stage_id.is_closed | ||
|
||
@api.depends("task_id.stage_id.is_closed") | ||
def _compute_done(self): | ||
for record in self: | ||
record.done = record.is_done() | ||
|
||
def name_get(self): | ||
result = [] | ||
|
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
66 changes: 66 additions & 0 deletions
66
project_workload/views/project_task_workload_unit_view.xml
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,66 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
|
||
<record id="project_workload_unit_view_tree" model="ir.ui.view"> | ||
<field name="model">project.workload.unit</field> | ||
<field name="arch" type="xml"> | ||
<tree string="Workload"> | ||
<field name="week" /> | ||
<field name="user_id" /> | ||
<field name="hours" /> | ||
<field name="project_id" /> | ||
<field name="task_id" optional="hide" /> | ||
<field name="workload_id" optional="hide" /> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="project_workload_unit_view_search" model="ir.ui.view"> | ||
<field name="model">project.workload.unit</field> | ||
<field name="arch" type="xml"> | ||
<search string="Workload"> | ||
<field name="week" /> | ||
<field name="user_id" /> | ||
<field name="project_id" /> | ||
<filter | ||
string="My load" | ||
name="my_load" | ||
domain="[('user_id', '=', uid), ('done', '=', False)]" | ||
/> | ||
<group expand="0" string="Group By"> | ||
<filter | ||
string="Week" | ||
name="groupby_week" | ||
domain="[]" | ||
context="{'group_by': 'week'}" | ||
/> | ||
<filter | ||
string="User" | ||
name="groupby_user" | ||
domain="[]" | ||
context="{'group_by': 'user_id'}" | ||
/> | ||
<filter | ||
string="Project" | ||
name="groupby_project" | ||
domain="[]" | ||
context="{'group_by': 'project_id'}" | ||
/> | ||
</group> | ||
</search> | ||
</field> | ||
</record> | ||
|
||
<record model="ir.actions.act_window" id="project_workload_unit_action"> | ||
<field name="name">Workload</field> | ||
<field name="type">ir.actions.act_window</field> | ||
<field name="res_model">project.workload.unit</field> | ||
<field name="view_mode">tree</field> | ||
<field name="search_view_id" ref="project_workload_unit_view_search" /> | ||
<field name="domain">[]</field> | ||
<field | ||
name="context" | ||
>{'search_default_my_load': 1, 'search_default_groupby_week': 1}</field> | ||
</record> | ||
|
||
</odoo> |
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