Skip to content

Commit eb92c78

Browse files
committed
feat(project_phase_estimate): enhance estimate views and add project action button
- Add sum aggregations to estimate tree view fields for planned, effective, and remaining hours with percentage progress - Implement action_view_estimates method to open estimates with pre-filled project context - Add kanban view inheritance to display "Phase Estimates" button when allow_estimate is enabled - Update README and USAGE.md to document validated_hours_only context parameter - Remove redundant SQL constraint and simplify project.estimate model structure - Improve field definitions with consistent naming and remove unused parameters
1 parent 66ed0fe commit eb92c78

File tree

6 files changed

+72
-27
lines changed

6 files changed

+72
-27
lines changed

project_phase_estimate/README.rst

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
======================
62
Project Phase Estimate
73
======================
@@ -17,12 +13,12 @@ Project Phase Estimate
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Beta
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
23-
.. |badge3| image:: https://img.shields.io/badge/github-Mint--System%2FOdoo--Apps--Project-lightgray.png?logo=github
24-
:target: https://github.com/Mint-System/Odoo-Apps-Project/tree/16.0/project_phase_estimate
25-
:alt: Mint-System/Odoo-Apps-Project
19+
.. |badge3| image:: https://img.shields.io/badge/github-Mint--System%2Ftemplate-lightgray.png?logo=github
20+
:target: https://github.com/Mint-System/template/tree/16.0/project_phase_estimate
21+
:alt: Mint-System/template
2622

2723
|badge1| |badge2| |badge3|
2824

@@ -36,15 +32,16 @@ Estimate planned hours by project and phases.
3632
Usage
3733
=====
3834

39-
35+
Set context "validated_hours_only" to True if only validated hours must
36+
be considered in effective hours calculation.
4037

4138
Bug Tracker
4239
===========
4340

44-
Bugs are tracked on `GitHub Issues <https://github.com/Mint-System/Odoo-Apps-Project/issues>`_.
41+
Bugs are tracked on `GitHub Issues <https://github.com/Mint-System/template/issues>`_.
4542
In case of trouble, please check there if your issue has already been reported.
4643
If you spotted it first, help us to smash it by providing a detailed and welcomed
47-
`feedback <https://github.com/Mint-System/Odoo-Apps-Project/issues/new?body=module:%20project_phase_estimate%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
44+
`feedback <https://github.com/Mint-System/template/issues/new?body=module:%20project_phase_estimate%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
4845

4946
Do not contact contributors directly about support or help with technical issues.
5047

@@ -64,6 +61,6 @@ Contributors
6461
Maintainers
6562
-----------
6663

67-
This module is part of the `Mint-System/Odoo-Apps-Project <https://github.com/Mint-System/Odoo-Apps-Project/tree/16.0/project_phase_estimate>`_ project on GitHub.
64+
This module is part of the `Mint-System/template <https://github.com/Mint-System/template/tree/16.0/project_phase_estimate>`_ project on GitHub.
6865

6966
You are welcome to contribute.

project_phase_estimate/models/project_estimate.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,16 @@ class ProjectEstimate(models.Model):
1414

1515
active = fields.Boolean(default=True)
1616
sequence = fields.Integer()
17-
project_id = fields.Many2one("project.project", string="Project")
17+
project_id = fields.Many2one("project.project")
1818
phase_id = fields.Many2one("project.task.phase", string="Project Phase")
1919

20-
_sql_constraints = [
21-
(
22-
"project_phase_unique",
23-
"unique(project_id, phase_id)",
24-
"The combination of project and phase must be unique.",
25-
),
26-
]
27-
2820
planned_date_begin = fields.Datetime("Start Date")
2921
planned_date_end = fields.Datetime("End Date")
3022

3123
planned_hours = fields.Float()
3224
effective_hours = fields.Float(compute="_compute_effective_hours", compute_sudo=True, store=False)
3325
remaining_hours = fields.Float(compute="_compute_remaining_hours", store=False)
34-
progress = fields.Float(compute="_compute_progress_hours", store=False)
26+
progress = fields.Float(compute="_compute_progress_hours", store=False, group_operator="avg")
3527

3628
def _compute_effective_hours(self):
3729
for estimate in self:

project_phase_estimate/models/project_project.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,13 @@ class ProjectProject(models.Model):
1010

1111
allow_estimate = fields.Boolean(default=True, help="Add estimates linked to phases to this project.")
1212
estimate_ids = fields.One2many("project.estimate", "project_id")
13+
14+
def action_view_estimates(self):
15+
self.ensure_one()
16+
return {
17+
"type": "ir.actions.act_window",
18+
"name": "Estimates",
19+
"res_model": "project.estimate",
20+
"view_mode": "tree,form",
21+
"context": {"default_project_id": self.id, "search_default_project_id": self.id},
22+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Set context "validated_hours_only" to True if only validated hours must be considered in effective hours calculation.

project_phase_estimate/views/project_estimate_views.xml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,29 @@
1111
<field name="phase_id" />
1212
<field name="planned_date_begin" optional="show" />
1313
<field name="planned_date_end" optional="show" />
14-
<field name="planned_hours" widget="timesheet_uom" />
15-
<field name="effective_hours" widget="timesheet_uom" optional="show" />
16-
<field name="remaining_hours" widget="timesheet_uom" optional="show" />
17-
<field name="progress" widget="progressbar" optional="show" />
14+
<field
15+
name="planned_hours"
16+
widget="timesheet_uom"
17+
sum="Total Planned Hours"
18+
/>
19+
<field
20+
name="effective_hours"
21+
widget="timesheet_uom"
22+
optional="show"
23+
sum="Total Effective Hours"
24+
/>
25+
<field
26+
name="remaining_hours"
27+
widget="timesheet_uom"
28+
optional="show"
29+
sum="Total Remaining Hours"
30+
/>
31+
<field
32+
name="progress"
33+
widget="progressbar"
34+
optional="show"
35+
sum="Project Progress (%)"
36+
/>
1837
</tree>
1938
</field>
2039
</record>

project_phase_estimate/views/project_project_views.xml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@
2626
</field>
2727
</record>
2828

29+
<record
30+
id="project_project_view_kanban_inherit_sale_timesheet_so_button"
31+
model="ir.ui.view"
32+
>
33+
<field
34+
name="name"
35+
>project_phase_estimate.project_project_view_kanban_inherit_sale_timesheet_so_button</field>
36+
<field name="model">project.project</field>
37+
<field name="inherit_id" ref="project.view_project_kanban" />
38+
<field name="priority">30</field>
39+
<field name="arch" type="xml">
40+
<xpath expr="//div[hasclass('o_kanban_manage_view')]" position="inside">
41+
<field name="allow_estimate" invisible="1" />
42+
<div t-if="record.allow_estimate.raw_value" role="menuitem">
43+
<a name="action_view_estimates" type="object">Phase Estimates</a>
44+
</div>
45+
</xpath>
46+
</field>
47+
</record>
2948

3049
<record id="edit_project" model="ir.ui.view">
3150
<field name="name">project_phase_estimate.edit_project</field>
@@ -50,21 +69,28 @@
5069
<field name="phase_id" />
5170
<field name="planned_date_begin" optional="show" />
5271
<field name="planned_date_end" optional="show" />
53-
<field name="planned_hours" widget="timesheet_uom" />
72+
<field
73+
name="planned_hours"
74+
widget="timesheet_uom"
75+
sum="Total Planned Hours"
76+
/>
5477
<field
5578
name="effective_hours"
5679
widget="timesheet_uom"
5780
optional="show"
81+
sum="Total Effective Hours"
5882
/>
5983
<field
6084
name="remaining_hours"
6185
widget="timesheet_uom"
6286
optional="show"
87+
sum="Total Remaining Hours"
6388
/>
6489
<field
6590
name="progress"
6691
widget="progressbar"
6792
optional="show"
93+
sum="Project Progress (%)"
6894
/>
6995
</tree>
7096
</field>

0 commit comments

Comments
 (0)