Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TA#72178 [MIG][16.0] project_projected_hours #468

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .docker_files/main/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"summary": "Install all addons required for testing.",
"depends": [
"project",
"project_projected_hours",
"project_task_date_planned",
"project_task_full_text_search",
"project_type_advanced",
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN gitoo install-all --conf_file /gitoo.yml --destination "${THIRD_PARTY_ADDONS

USER odoo

COPY project_projected_hours mnt/extra-addons/project_projected_hours
COPY project_stage_allow_timesheet mnt/extra-addons/project_stage_allow_timesheet
COPY project_task_date_planned /mnt/extra-addons/project_task_date_planned
COPY project_task_full_text_search /mnt/extra-addons/project_task_full_text_search
Expand Down
24 changes: 24 additions & 0 deletions project_projected_hours/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Project Projected Hours
=======================
This module allows to:

* Add “Projected Hours” in the form view of a task.
Computed as : task effective hours + task remaining hours.

.. image:: static/description/task_projected_hours.png

* Add the "Real progress” field in the form view of a task
Computed as : task effective hours / (task effective hours + task remaining hours).

.. image:: static/description/task_real_progress.png

* Add a “Task Progress” analysis list view
* Add a list view with the elements to filter and group excluding the variance on progress

.. image:: static/description/task_progress_menu.png

.. image:: static/description/task_progress_report.png

Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)
4 changes: 4 additions & 0 deletions project_projected_hours/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models

Check notice on line 4 in project_projected_hours/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

project_projected_hours/__init__.py#L4

'.models' imported but unused (F401)
19 changes: 19 additions & 0 deletions project_projected_hours/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{

Check warning on line 4 in project_projected_hours/__manifest__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

project_projected_hours/__manifest__.py#L4

Statement seems to have no effect
"name": "Project Projected Hours",
"version": "1.0.2",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://bit.ly/numigi-com",
"license": "AGPL-3",
"category": "Project",
"depends": ["project_remaining_hours_update"],
"summary": "Add some progress time on task",
"data": [
"views/project_task_progress_report_views.xml",
"views/project_task_views.xml",
],
"installable": True,
}
39 changes: 39 additions & 0 deletions project_projected_hours/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_projected_hours
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-29 12:53+0000\n"
"PO-Revision-Date: 2024-11-29 12:53+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: project_projected_hours
#: model:ir.model.fields,field_description:project_projected_hours.field_project_task__projected_hours
msgid "Projected Hours"
msgstr "Heures projetées"

#. module: project_projected_hours
#: model:ir.model.fields,field_description:project_projected_hours.field_project_task__real_progress
msgid "Real Progress"
msgstr "Avancement réel"

#. module: project_projected_hours
#: model:ir.model,name:project_projected_hours.model_project_task
#: model_terms:ir.ui.view,arch_db:project_projected_hours.view_task_project_progress_tree
msgid "Task"
msgstr "Tâche"

#. module: project_projected_hours
#: model:ir.actions.act_window,name:project_projected_hours.action_project_task_progress_tree
#: model:ir.ui.menu,name:project_projected_hours.menu_project_report_task_progress
#: model_terms:ir.ui.view,arch_db:project_projected_hours.view_task_project_progress_tree
msgid "Tasks Progress"
msgstr "Avancement des tâches"
4 changes: 4 additions & 0 deletions project_projected_hours/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import project_task

Check notice on line 4 in project_projected_hours/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

project_projected_hours/models/__init__.py#L4

'.project_task' imported but unused (F401)
34 changes: 34 additions & 0 deletions project_projected_hours/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class ProjectTask(models.Model):
_inherit = "project.task"

projected_hours = fields.Float(
"Projected Hours",
compute="_compute_project_data",
store=True,
)
real_progress = fields.Float(
"Real Progress",
digits=(16, 2),
compute="_compute_project_data",
store=True,
)

@api.depends("effective_hours", "remaining_hours")
def _compute_project_data(self):
"""Compute projected hours and real progress."""
for task in self:
effective_hours, remaining_hours = (
task.effective_hours,
task.remaining_hours,
)
projected_hours = effective_hours + remaining_hours
task.projected_hours = projected_hours
task.real_progress = (
100.0 * effective_hours / projected_hours if projected_hours else 0.0
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions project_projected_hours/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_projected_hours
50 changes: 50 additions & 0 deletions project_projected_hours/tests/test_projected_hours.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import datetime

from odoo.tests.common import TransactionCase


class TestCustomerReference(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.project = cls.env["project.project"].create(
{"name": "test_project", "allow_timesheets": True}
)
cls.task_1 = cls.env["project.task"].create(
{"name": "test_task_1", "project_id": cls.project.id}
)

cls.task_2 = cls.env["project.task"].create(
{"name": "test_task_2", "project_id": cls.project.id}
)

def test_projected_hours(self):
self.task_1.planned_hours = 10
self._create_analytic_line(
datetime(2023, 3, 24, 3), tz="EST", task_id=self.task_1, unit_amount=1
)
self.assertEqual(self.task_1.projected_hours, 10)

def test_real_progress(self):
self.assertEqual(self.task_2.real_progress, 0)
self.task_2.planned_hours = 20
self._create_analytic_line(
datetime(2023, 3, 24, 3), tz="EST", task_id=self.task_2, unit_amount=3
)

self.assertEqual(self.task_2.real_progress, 15)

def _create_analytic_line(self, date, tz=None, task_id=False, unit_amount=0):
self.env["account.analytic.line"].with_context(tz=tz).create(
{
"date": date,
"project_id": self.project.id,
"task_id": task_id.id,
"name": "Test line",
"unit_amount": unit_amount,
"employee_id": self.ref("hr.employee_admin"),
}
)
26 changes: 26 additions & 0 deletions project_projected_hours/views/project_task.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>

<record model="ir.ui.view" id="view_task_form2_inherited">
<field name="name">project.task.form.inherited</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="hr_timesheet.view_task_form2_inherited" />
<field name="groups_id" eval="[(6,0, (ref('hr_timesheet.group_hr_timesheet_user'),))]"/>
<field name="arch" type="xml">
<field name="remaining_hours" position="after">
<field name="projected_hours" widget="float_time" class="oe_subtotal_footer_separator"/>
</field>
<field name="progress" position="after">
<field name="real_progress" widget="progressbar"/>
</field>
</field>
</record>

<menuitem id="menu_project_report_task_progress"
name="Tasks Progress"
action="project_projected_hours.action_project_task_progress_tree"
parent="project.menu_project_report"
groups="project.group_project_manager"
sequence="30"/>

</odoo>
28 changes: 28 additions & 0 deletions project_projected_hours/views/project_task_progress_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<record id="view_task_project_progress_tree" model="ir.ui.view">
<field name="name">report.project.task.progress.tree</field>
<field name="model">project.task</field>
<field name="arch" type="xml">
<tree string="Tasks Progress" create="false" default_order="id desc">
<field name="project_id"/>
<field name="name" string="Task"/>
<field name="planned_hours"/>
<field name="effective_hours"/>
<field name="remaining_hours"/>
<field name="projected_hours"/>
<field name="progress"/>
<field name="real_progress"/>
</tree>
</field>
</record>

<record id="action_project_task_progress_tree" model="ir.actions.act_window">
<field name="name">Tasks Progress</field>
<field name="res_model">project.task</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_task_project_progress_tree"/>
</record>

</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<record id="view_task_project_progress_tree" model="ir.ui.view">
<field name="name">report.project.task.progress.tree</field>
<field name="model">project.task</field>
<field name="arch" type="xml">
<tree string="Tasks Progress" create="false" default_order="id desc">
<field name="project_id"/>
<field name="name" string="Task"/>
<field name="planned_hours"/>
<field name="effective_hours"/>
<field name="remaining_hours"/>
<field name="projected_hours"/>
<field name="progress"/>
<field name="real_progress"/>
</tree>
</field>
</record>

<record id="action_project_task_progress_tree" model="ir.actions.act_window">
<field name="name">Tasks Progress</field>
<field name="res_model">project.task</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_task_project_progress_tree"/>
</record>

</odoo>
26 changes: 26 additions & 0 deletions project_projected_hours/views/project_task_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>

<record model="ir.ui.view" id="view_task_form2_inherited">
<field name="name">project.task.form.inherited</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="hr_timesheet.view_task_form2_inherited" />
<field name="arch" type="xml">
<field name="remaining_hours" position="after">
<field name="projected_hours" widget="float_time" class="oe_subtotal_footer_separator" groups="hr_timesheet.group_hr_timesheet_user"/>
</field>
<field name="progress" position="after">
<field name="real_progress" widget="progressbar" groups="hr_timesheet.group_hr_timesheet_user"/>
</field>
</field>
</record>

<menuitem id="menu_project_report_task_progress"
name="Tasks Progress"
action="project_projected_hours.action_project_task_progress_tree"
parent="project.menu_project_report"
groups="project.group_project_manager"
sequence="30"
/>

</odoo>
Loading