From 31775201512aa6b5e235ea38b2a293f902f138bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Grand-Guillaume?= Date: Fri, 12 Aug 2011 14:33:12 +0200 Subject: [PATCH 01/14] [ADD] First commit of the first generic modules to move in our new public branch (lp:c2c-addons/6.1 rev 1) --- project_indicators/__init__.py | 31 +++++ project_indicators/__openerp__.py | 54 ++++++++ project_indicators/project.py | 81 ++++++++++++ project_indicators/project_view.xml | 108 ++++++++++++++++ project_indicators/report.xml | 14 +++ project_indicators/report/__init__.py | 1 + .../report/project_tracking.mako | 117 ++++++++++++++++++ project_indicators/report/project_tracking.py | 63 ++++++++++ 8 files changed, 469 insertions(+) create mode 100644 project_indicators/__init__.py create mode 100644 project_indicators/__openerp__.py create mode 100644 project_indicators/project.py create mode 100644 project_indicators/project_view.xml create mode 100644 project_indicators/report.xml create mode 100644 project_indicators/report/__init__.py create mode 100644 project_indicators/report/project_tracking.mako create mode 100644 project_indicators/report/project_tracking.py diff --git a/project_indicators/__init__.py b/project_indicators/__init__.py new file mode 100644 index 0000000..77348d8 --- /dev/null +++ b/project_indicators/__init__.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2010 Camptocamp SA +# @author Guewen Baconnier +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import project +import report diff --git a/project_indicators/__openerp__.py b/project_indicators/__openerp__.py new file mode 100644 index 0000000..ef2d037 --- /dev/null +++ b/project_indicators/__openerp__.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2010 Camptocamp SA +# @author Guewen Baconnier +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + + +{ + "name" : "Project indicators", + "version" : "1.0", + "author" : "Camptocamp", + "category" : "Generic Modules/Projects & Services", + "description": +""" +This modules adds indicators on project : + - a popup window on the project view which display the indicators of its analytic account. + - fields with planned vs effective difference + - a report for the tracking of the projects (based on report_webkit) + +""", + "website": "http://camptocamp.com", + "depends" : ['project', + 'report_webkit'], + "init_xml" : [], + "demo_xml" : [], + "update_xml" : ['project_view.xml', + 'report.xml', + ], + "active": False, + "installable": True +} diff --git a/project_indicators/project.py b/project_indicators/project.py new file mode 100644 index 0000000..de5acf6 --- /dev/null +++ b/project_indicators/project.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2010 Camptocamp SA +# @author Guewen Baconnier +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +from osv import osv, fields + + +class Project(osv.osv): + _inherit = "project.project" + + def open_project_indicators(self, cr, uid, ids, context=None): + ir_model_data_obj = self.pool.get('ir.model.data') + ir_model_data_id = ir_model_data_obj.search(cr, uid, + [['model', '=', 'ir.ui.view'], + ['name', '=', 'account_analytic_account_wizard_indicators']], + context=context) + res_id = ir_model_data_obj.read(cr, uid, ir_model_data_id, + fields=['res_id'])[0]['res_id'] + + if isinstance(ids, list): + ids = ids[0] + + project = self.browse(cr, uid, ids, context=context) + account_id = project.analytic_account_id.id + + return { + 'name': 'Project indicators', + 'view_type': 'form', + 'view_mode': 'form', + 'view_id': [res_id], + 'res_model': 'account.analytic.account', + 'context': '{}', + 'type': 'ir.actions.act_window', + 'nodestroy': True, + 'target': 'new', + 'res_id': account_id, + } + +Project() + + +class ProjectTask(osv.osv): + _inherit = 'project.task' + + def _get_planning_error(self, cr, uid, ids, field_names, args, context=None): + res = {}.fromkeys(ids, 0.0) + for task in self.browse(cr, uid, ids, context=context): + if task.delay_hours and task.planned_hours: + res[task.id] = round(100.0 * task.delay_hours / task.planned_hours, 2) + return res + + _columns = { + 'planning_error_percentage': fields.function(_get_planning_error, method=True, string='Error (%)', type='float', group_operator="avg", help="Computed as: Delay Hours / Planned Hours."), + } + +ProjectTask() diff --git a/project_indicators/project_view.xml b/project_indicators/project_view.xml new file mode 100644 index 0000000..98cb024 --- /dev/null +++ b/project_indicators/project_view.xml @@ -0,0 +1,108 @@ + + + + + #--------------------------------------------------------------------------------------------------------- + # Add a button to open the analytic account indicators on the project view + #--------------------------------------------------------------------------------------------------------- + + project.project.form.indicators + project.project + form + + + +