From aca5e3f7377e0b8bb4680e28d8432b2210013785 Mon Sep 17 00:00:00 2001 From: Chandresh Thakkar Date: Thu, 21 Jun 2018 14:53:49 +0530 Subject: [PATCH 1/2] [MIG] Migrated the module from 8.0 to 9.0 --- oca_dependencies.txt | 1 + project_indicators/README.rst | 48 +++++++ project_indicators/__init__.py | 2 +- project_indicators/__openerp__.py | 17 +-- project_indicators/models/__init__.py | 4 + project_indicators/models/project.py | 47 ++++++ project_indicators/project.py | 80 ----------- project_indicators/project_view.xml | 108 -------------- project_indicators/report.xml | 14 -- project_indicators/report/__init__.py | 4 + project_indicators/report/project_tracking.py | 42 ++++-- .../report/project_tracking.xml | 56 ++++++++ .../report/wiz_project_tracking_indicator.py | 134 ++++++++++++++++++ project_indicators/views/project_view.xml | 50 +++++++ project_indicators/views/report.xml | 23 +++ 15 files changed, 411 insertions(+), 219 deletions(-) create mode 100644 project_indicators/README.rst create mode 100644 project_indicators/models/__init__.py create mode 100644 project_indicators/models/project.py delete mode 100644 project_indicators/project.py delete mode 100644 project_indicators/project_view.xml delete mode 100644 project_indicators/report.xml create mode 100644 project_indicators/report/project_tracking.xml create mode 100644 project_indicators/report/wiz_project_tracking_indicator.py create mode 100644 project_indicators/views/project_view.xml create mode 100644 project_indicators/views/report.xml diff --git a/oca_dependencies.txt b/oca_dependencies.txt index 376cc3e..fdd4360 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1,3 +1,4 @@ # list the OCA project dependencies, one per line # add a github url if you need a forked version project-service +reporting-engine diff --git a/project_indicators/README.rst b/project_indicators/README.rst new file mode 100644 index 0000000..9acb49e --- /dev/null +++ b/project_indicators/README.rst @@ -0,0 +1,48 @@ +.. 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. +We are introducing the Project Tracking Report in the XLS format with this module. PDF report is already there. + + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + + +Credits +======= + +Contributors +------------ + +* Camptocamp +* Serpent Consulting Services Pvt. Ltd. + +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. diff --git a/project_indicators/__init__.py b/project_indicators/__init__.py index c731068..49f5d49 100644 --- a/project_indicators/__init__.py +++ b/project_indicators/__init__.py @@ -27,5 +27,5 @@ # ############################################################################## -from . import project +from . import models from . import report diff --git a/project_indicators/__openerp__.py b/project_indicators/__openerp__.py index e228b12..798411d 100644 --- a/project_indicators/__openerp__.py +++ b/project_indicators/__openerp__.py @@ -31,7 +31,8 @@ { "name": "Project indicators", "version": "1.0", - "author": "Camptocamp,Odoo Community Association (OCA)", + "author": "Camptocamp,Odoo Community Association (OCA), " + "Serpent Consulting Services Pvt. Ltd.", "category": "Generic Modules/Projects & Services", "description": """ @@ -43,11 +44,11 @@ - a report for the tracking of the projects (based on report_webkit) """, "website": "http://camptocamp.com", - "depends": ['project', - 'account_analytic_analysis', - 'report_webkit'], - "data": ['project_view.xml', - 'report.xml'], - "active": False, - "installable": False, + "depends": ['project_timesheet', + 'report_webkit', + 'report_xlsx'], + "data": ['views/project_view.xml', + 'views/report.xml', + 'report/project_tracking.xml'], + "installable": True, } diff --git a/project_indicators/models/__init__.py b/project_indicators/models/__init__.py new file mode 100644 index 0000000..50995db --- /dev/null +++ b/project_indicators/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import project diff --git a/project_indicators/models/project.py b/project_indicators/models/project.py new file mode 100644 index 0000000..a59d6c2 --- /dev/null +++ b/project_indicators/models/project.py @@ -0,0 +1,47 @@ +# -*- 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 openerp import api, models, fields + + +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.") diff --git a/project_indicators/project.py b/project_indicators/project.py deleted file mode 100644 index 7bf3c9b..0000000 --- a/project_indicators/project.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- 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, - } - - -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."), - } diff --git a/project_indicators/project_view.xml b/project_indicators/project_view.xml deleted file mode 100644 index 98cb024..0000000 --- a/project_indicators/project_view.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - #--------------------------------------------------------------------------------------------------------- - # Add a button to open the analytic account indicators on the project view - #--------------------------------------------------------------------------------------------------------- - - project.project.form.indicators - project.project - form - - - -