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

[11.0] [MIG] project_indicators: Migrated module in v11. #26

Open
wants to merge 14 commits into
base: 11.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
3 changes: 3 additions & 0 deletions oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# list the OCA project dependencies, one per line
# add a github url if you need a forked version
project
53 changes: 53 additions & 0 deletions project_indicators/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3

Project Indicators
=================================================


You can track your all the project status with the respective tasks list.
Also you can print the Project Tracking Report in PDF format.


For further information, please visit:

* https://www.odoo.com/forum/help-1


.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/139/11.0


Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/project-reporting/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/project-reporting/issues/new?body=module:%20project_billing_utils%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly add usage section so it will help end user to check on runbot.
https://raw.githubusercontent.com/OCA/maintainer-tools/master/template/module/README.rst

Credits
=======

Contributors
------------

* Camptocamp <[email protected]>
* Serpent Consulting Services Pvt. Ltd. <[email protected]>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit http://odoo-community.org.
9 changes: 9 additions & 0 deletions project_indicators/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
##############################################################################
#
# Copyright (c) 2010 Camptocamp SA
# @author Guewen Baconnier
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
##############################################################################

from . import models
from . import report
23 changes: 23 additions & 0 deletions project_indicators/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
##############################################################################
#
# Copyright (c) 2010 Camptocamp SA
# @author Guewen Baconnier
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
##############################################################################


{
"name": "Project indicators",
"version": "11.0.1.0.0",
"author": "Camptocamp,Odoo Community Association (OCA)",
"category": "Generic Modules/Projects & Services",
"website": "http://camptocamp.com",
"license": "AGPL-3",
"depends": ['sale_timesheet',
'web'],
"data": ['views/project_view.xml',
'views/report.xml',
'report/project_tracking.xml'],
"application": False,
"installable": True,
}
3 changes: 3 additions & 0 deletions project_indicators/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import project
25 changes: 25 additions & 0 deletions project_indicators/models/project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
##############################################################################
#
# Copyright (c) 2010 Camptocamp SA
# @author Guewen Baconnier
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
##############################################################################

from odoo import models, fields, api


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

@api.multi
@api.depends('delay_hours', 'planned_hours')
def _get_planning_error(self):
for task in self:
if task.delay_hours and task.planned_hours:
task.planning_error_percentage = round(
100.0 * task.delay_hours / task.planned_hours, 2)

planning_error_percentage = fields.Float(
compute='_get_planning_error', string='Error (%)',
group_operator="avg",
help="Computed as: Delay Hours / Planned Hours.")
3 changes: 3 additions & 0 deletions project_indicators/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import project_tracking
68 changes: 68 additions & 0 deletions project_indicators/report/project_tracking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
##############################################################################
#
# Copyright (c) 2010 Camptocamp SA
# @author Guewen Baconnier
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
##############################################################################

import math
from odoo import models, api


class ProjectTrackingQwebReport(models.AbstractModel):

_name = 'report.project_indicators.project_tracking'

@api.multi
def float_time_convert(self, float_val):
sign = float_val < 0 and '-' or ''
hours = math.floor(abs(float_val))
mins = round(abs(float_val) % 1 + 0.01, 2)
if mins >= 1.0:
hours += 1
mins = 0.0
else:
mins *= 60
float_time = '%s%02d:%02d' % (sign, hours, mins)
return float_time

@api.multi
def total_project_analysis(self, project_id):
res = {}
effective_hours = 0.0
remaining_hours = 0.0
total_hours = 0.0
planned_hours = 0.0
delay_hours = 0.0
planning_error_percentage = 0.0
for task in project_id.tasks:
effective_hours += task.effective_hours
remaining_hours += task.remaining_hours
total_hours += task.total_hours
planned_hours += task.planned_hours
delay_hours += task.delay_hours
planning_error_percentage += task.planning_error_percentage
res.update({'effective_hours': effective_hours,
'remaining_hours': remaining_hours,
'total_hours': total_hours,
'planned_hours': planned_hours,
'delay_hours': delay_hours,
'planning_error_percentage': planning_error_percentage
})
return [res]

@api.model
def get_report_values(self, docids, data=None):
docs = self.env['project.project'].browse(docids)
if data is None:
data = {}
if not docids:
docids = data.get('docids')
return {
'doc_ids': docids,
'doc_model': 'project.project',
'data': data,
'docs': docs,
'float_time_convert': self.float_time_convert,
'total_project': self.total_project_analysis
}
55 changes: 55 additions & 0 deletions project_indicators/report/project_tracking.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="project_tracking">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="project">
<t t-call="web.external_layout">
<div class="page">
<br/>
<br/>
<div style="text-align:center"><b>Project:<t t-esc="project.name"/></b></div>
<br/>
<table class="table table-bordered table-condensed" width="100%">
<tr style="background-color:#D9D8CA;">
<td style="border: 1px solid #000000;text-align:center;width:100%;" colspan="2"><b>Total (With Timesheets)</b></td>
</tr>
</table>
<br/>
<br/>
<table class="table table-bordered table-condensed" width="100%">
<tr style="background-color:#D9D8CA;text-align:center;">
<td style="border: 1px solid #000000;"><b>Task</b></td>
<td style="border: 1px solid #000000;"><b>Status</b></td>
<td style="border: 1px solid #000000;"><b>Hours Spent</b></td>
<td style="border: 1px solid #000000;"><b>Remaining Hours</b></td>
<td style="border: 1px solid #000000;"><b>Total Hours</b></td>
<td style="border: 1px solid #000000;"><b>Planned Hours</b></td>
<td style="border: 1px solid #000000;"><b>Delay Hours</b></td>
<td style="border: 1px solid #000000;"><b>Error (%)</b></td>
</tr>
<tr style="text-align:center;" t-foreach="project.tasks" t-as="task">
<td style="border: 1px solid #000000;"><span t-esc="task.name"/></td>
<td style="border: 1px solid #000000;"><span t-esc="task.stage_id and task.stage_id.name or ''"/></td>
<td style="border: 1px solid #000000;"><span t-esc="float_time_convert(task.effective_hours)"/></td>
<td style="border: 1px solid #000000;"><span t-esc="task.remaining_hours &lt; 0 and 'exceeded' or ''"/><span t-esc="float_time_convert(task.remaining_hours)"/></td>
<td style="border: 1px solid #000000;"><span t-esc="float_time_convert(task.total_hours)"/></td>
<td style="border: 1px solid #000000;"><span t-esc="float_time_convert(task.planned_hours)"/></td>
<td style="border: 1px solid #000000;"><span t-esc="float_time_convert(task.delay_hours)"/></td>
<td style="border: 1px solid #000000;"><span t-esc="task.planning_error_percentage or 0"/></td>
</tr>
<tr style="text-align:center;" t-foreach="total_project(project)" t-as="task_total">
<td style="border: 1px solid #000000;" colspan="2"><b>Totals</b></td>
<td style="border: 1px solid #000000;"><span t-esc="float_time_convert(task_total['effective_hours'])"/></td>
<td style="border: 1px solid #000000;"><span t-esc="float_time_convert(task_total['total_hours'] - task_total['effective_hours'])"/></td>
<td style="border: 1px solid #000000;"><span t-esc="float_time_convert(task_total['total_hours'])"/></td>
<td style="border: 1px solid #000000;"><span t-esc="float_time_convert(task_total['planned_hours'])"/></td>
<td style="border: 1px solid #000000;"><span t-esc="float_time_convert(task_total['total_hours'] - task_total['planned_hours'])"/></td>
<td style="border: 1px solid #000000;"><span t-esc="task_total['planned_hours'] and round((task_total['total_hours'] - task_total['planned_hours']) / task_total['planned_hours'] * 100, 2) or 0"/></td>
</tr>
</table>
</div>
</t>
</t>
</t>
</template>
</odoo>
46 changes: 46 additions & 0 deletions project_indicators/views/project_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
#---------------------------------------------------------------------------------------------------------
# Add useful fields on task view tree
#---------------------------------------------------------------------------------------------------------
<record id="view_task_tree2_time_fields" model="ir.ui.view">
<field name="name">project.task.tree.time.fields</field>
<field name="model">project.task</field>
<field name="type">tree</field>
<field name="inherit_id" ref="project.view_task_tree2" />
<field name="arch" type="xml">
<data>
<field name="planned_hours" position="replace">
<field name="planned_hours" widget="float_time" sum="Planned Hours" />
</field>
<field name="total_hours" position="replace">
<field name="total_hours" widget="float_time" sum="Total Hours" />
</field>
<field name="effective_hours" position="replace">
<field name="effective_hours" widget="float_time" sum="Spent Hours"/>
</field>
<field name="remaining_hours" position="after">
<field name="delay_hours" widget="float_time" sum="Delay Hours"/>
<field name="planning_error_percentage" sum="Percentage Error"/>
</field>
</data>
</field>
</record>

#---------------------------------------------------------------------------------------------------------
# Add useful fields on task view form
#---------------------------------------------------------------------------------------------------------
<record id="view_task_form2_time_fields" model="ir.ui.view">
<field name="name">project.task.form.time.fields</field>
<field name="model">project.task</field>
<field name="type">form</field>
<field name="inherit_id" ref="hr_timesheet.view_task_form2_inherited" />
<field name="arch" type="xml">
<field name="progress" position="after">
<field name="delay_hours" widget="float_time" sum="Delay Hours"/>
<field name="planning_error_percentage" sum="Percentage Error"/>
</field>
</field>
</record>

</odoo>
11 changes: 11 additions & 0 deletions project_indicators/views/report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<report auto="False"
id="report_project_tracking_indicator"
model="project.project"
name="project_indicators.project_tracking"
string="Project Tracking"
report_type="qweb-pdf"/>

</odoo>