From dddea1b77645faf9cf8c59cd00ede4384c8336e4 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Thu, 12 Apr 2012 13:40:52 +0200 Subject: [PATCH 01/40] [ADD] mgmtsystem_kpi --- mgmtsystem_kpi/__init__.py | 22 ++++ mgmtsystem_kpi/__openerp__.py | 43 ++++++++ mgmtsystem_kpi/mgmtsystem_kpi.py | 98 +++++++++++++++++ mgmtsystem_kpi/mgmtsystem_kpi.xml | 174 ++++++++++++++++++++++++++++++ 4 files changed, 337 insertions(+) create mode 100755 mgmtsystem_kpi/__init__.py create mode 100755 mgmtsystem_kpi/__openerp__.py create mode 100644 mgmtsystem_kpi/mgmtsystem_kpi.py create mode 100644 mgmtsystem_kpi/mgmtsystem_kpi.xml diff --git a/mgmtsystem_kpi/__init__.py b/mgmtsystem_kpi/__init__.py new file mode 100755 index 000000000..e8abd7249 --- /dev/null +++ b/mgmtsystem_kpi/__init__.py @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2012 Savoir-faire Linux (). +# +# 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 3 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, see . +# +############################################################################## +import mgmtsystem_kpi +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/mgmtsystem_kpi/__openerp__.py b/mgmtsystem_kpi/__openerp__.py new file mode 100755 index 000000000..6df182a03 --- /dev/null +++ b/mgmtsystem_kpi/__openerp__.py @@ -0,0 +1,43 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2012 Savoir-faire Linux (). +# +# 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 3 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, see . +# +############################################################################## +{ + "name" : "Key Performance Indicator", + "version" : "0.1", + "author" : "Savoir-faire Linux", + "website" : "http://www.savoirfairelinux.com", + "license" : "GPL-3", + "category" : "Management System", + "complexity" : "normal", + "description": """ + This module provides the basis for creating key performance indicators, + including static and dynamic thresholds. + """, + "depends" : ['mgmtsystem'], + "init_xml" : [], + "update_xml" : [ + 'mgmtsystem_kpi.xml', + ], + "demo_xml" : [], + "installable" : True, + "certificate" : '' +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/mgmtsystem_kpi/mgmtsystem_kpi.py b/mgmtsystem_kpi/mgmtsystem_kpi.py new file mode 100644 index 000000000..aa2a422e3 --- /dev/null +++ b/mgmtsystem_kpi/mgmtsystem_kpi.py @@ -0,0 +1,98 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2012 Savoir-faire Linux (). +# +# 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 3 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, see . +# +############################################################################## + +from osv import fields, osv + +class mgmtsystem_kpi_category(osv.osv): + """ + KPI Category + """ + _name = "mgmtsystem.kpi.category" + _description = "KPI Category" + _columns = { + 'name': fields.char('Name', size=50, required=True), + 'description': fields.text('Description') + } + +mgmtsystem_kpi_category() + +class mgmtsystem_kpi_threshold_range(osv.osv): + """ + KPI Threshold Range + """ + _name = "mgmtsystem.kpi.threshold.range" + _description = "KPI Threshold Range" + + _columns = { + 'name': fields.char('Name', size=50, required=True), + 'min': fields.float('Minimum', required=True), + 'max': fields.float('Maximum', size=50, required=True), + 'color': fields.char('Color (RGB code)', size=7, required=True), + } + +mgmtsystem_kpi_threshold_range() + +class mgmtsystem_kpi_threshold(osv.osv): + """ + KPI Threshold + """ + _name = "mgmtsystem.kpi.threshold" + _description = "KPI Threshold" + + _columns = { + 'name': fields.char('Name', size=50, required=True), + 'range_ids': fields.many2many('mgmtsystem.kpi.threshold.range','mgmtsystem_kpi_threshold_range_rel', 'threshold_id', 'range_id', 'Range', required=True), + } + +mgmtsystem_kpi_threshold() + +class mgmtsystem_kpi_periodicity_uom(osv.osv): + """ + Unit of Measure for Periodicity + """ + _name = "mgmtsystem.kpi.periodicity.uom" + _description = "Periodicity Unit of Measure" + + _columns = { + 'name': fields.char('Name', size=10, required=True), + } + +mgmtsystem_kpi_threshold() + +class mgmtsystem_kpi(osv.osv): + """ + Key Performance Indicators + """ + _name = "mgmtsystem.kpi" + _description = "Key Performance Indicator" + _columns = { + 'name': fields.char('Name', size=50, required=True), + 'description': fields.text('Description'), + 'category_id': fields.many2one('mgmtsystem.kpi.category','Category', required=True), + 'threshold_id': fields.many2one('mgmtsystem.kpi.threshold','Threshold', required=True), + 'periodicity': fields.integer('Periodicity'), + 'periodicity_uom': fields.many2one('mgmtsystem.kpi.periodicity.uom','Periodicity UoM', required=True), + 'value': fields.float('Value'), + } + +mgmtsystem_kpi() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/mgmtsystem_kpi/mgmtsystem_kpi.xml b/mgmtsystem_kpi/mgmtsystem_kpi.xml new file mode 100644 index 000000000..207a56d8c --- /dev/null +++ b/mgmtsystem_kpi/mgmtsystem_kpi.xml @@ -0,0 +1,174 @@ + + + + + + + + mgmtsystem.kpi.tree + mgmtsystem.kpi + tree + + + + + + + + + + + + mgmtsystem.kpi.form + mgmtsystem.kpi + form + +
+ + + + + + + + + + + + +
+ + + + + Key Performance Indicators + mgmtsystem.kpi + form + tree,form + + + + + + + mgmtsystem.kpi.threshold.tree + mgmtsystem.kpi.threshold + tree + + + + + + + + + mgmtsystem.kpi.threshold.form + mgmtsystem.kpi.threshold + form + +
+ + + + + + + + + +
+
+ + + + + + + Thresholds + mgmtsystem.kpi.threshold + form + tree,form + + + + + + + mgmtsystem.kpi.threshold.range.tree + mgmtsystem.kpi.threshold.range + tree + + + + + + + + + + + + mgmtsystem.kpi.threshold.range.form + mgmtsystem.kpi.threshold.range + form + +
+ + + + + + + + +
+ + + + + Ranges + mgmtsystem.kpi.threshold.range + form + tree,form + + + + + + + Hour + + + + Day + + + + Week + + + + Month + + +
+
From 61161911db02ee99918db785288556f452cc8cb2 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Sun, 6 May 2012 18:42:10 -0400 Subject: [PATCH 02/40] [IMP] Views. Computation code left to do. --- mgmtsystem_kpi/mgmtsystem_kpi.py | 31 ++++++++++++-- mgmtsystem_kpi/mgmtsystem_kpi.xml | 71 ++++++++++++++++++------------- 2 files changed, 69 insertions(+), 33 deletions(-) diff --git a/mgmtsystem_kpi/mgmtsystem_kpi.py b/mgmtsystem_kpi/mgmtsystem_kpi.py index aa2a422e3..fdfac289c 100644 --- a/mgmtsystem_kpi/mgmtsystem_kpi.py +++ b/mgmtsystem_kpi/mgmtsystem_kpi.py @@ -41,11 +41,27 @@ class mgmtsystem_kpi_threshold_range(osv.osv): _name = "mgmtsystem.kpi.threshold.range" _description = "KPI Threshold Range" + def _compute_min_value(self, cr, uid, ids, field_name, arg, context=None): + result = {} + + return result + + def _compute_max_value(self, cr, uid, ids, field_name, arg, context=None): + result = {} + + return result + _columns = { 'name': fields.char('Name', size=50, required=True), - 'min': fields.float('Minimum', required=True), - 'max': fields.float('Maximum', size=50, required=True), - 'color': fields.char('Color (RGB code)', size=7, required=True), + 'min_type': fields.selection((('static','Fixed value'), ('dynamic','Computed value')), 'Min Type', required=True), + 'min_value': fields.function(_compute_min_value, string='Minimum', type='float'), + 'min_fixed_value': fields.float('Minimum'), + 'min_code': fields.text('Minimum Computation Code'), + 'max_type': fields.selection((('static','Fixed value'), ('dynamic','Computed value')), 'Max Type', required=True), + 'max_value': fields.function(_compute_max_value, string='Maximum', type='float'), + 'max_fixed_value': fields.float('Maximum'), + 'max_code': fields.text('Maximum Computation Code'), + 'color': fields.char('Color', help='RGB code with #', size=7, required=True), } mgmtsystem_kpi_threshold_range() @@ -83,6 +99,12 @@ class mgmtsystem_kpi(osv.osv): """ _name = "mgmtsystem.kpi" _description = "Key Performance Indicator" + + def _compute_kpi_value(self, cr, uid, ids, field_name, arg, context=None): + result= {} + + return result + _columns = { 'name': fields.char('Name', size=50, required=True), 'description': fields.text('Description'), @@ -90,7 +112,8 @@ class mgmtsystem_kpi(osv.osv): 'threshold_id': fields.many2one('mgmtsystem.kpi.threshold','Threshold', required=True), 'periodicity': fields.integer('Periodicity'), 'periodicity_uom': fields.many2one('mgmtsystem.kpi.periodicity.uom','Periodicity UoM', required=True), - 'value': fields.float('Value'), + 'value': fields.function(_compute_kpi_value, string='Value', type='float'), + 'kpi_code': fields.text('KPI Computation Code'), } mgmtsystem_kpi() diff --git a/mgmtsystem_kpi/mgmtsystem_kpi.xml b/mgmtsystem_kpi/mgmtsystem_kpi.xml index 207a56d8c..cf0086c6a 100644 --- a/mgmtsystem_kpi/mgmtsystem_kpi.xml +++ b/mgmtsystem_kpi/mgmtsystem_kpi.xml @@ -33,18 +33,13 @@ - + + + - - Key Performance Indicators mgmtsystem.kpi @@ -53,6 +48,13 @@ + + @@ -76,8 +78,9 @@ - - + + + @@ -90,13 +93,6 @@ groups="base.group_mgmtsystem_manager" sequence="20"/> - - Thresholds mgmtsystem.kpi.threshold @@ -105,6 +101,13 @@ + + @@ -114,8 +117,8 @@ - - + + @@ -128,22 +131,25 @@
+ - - + - + + + + + + + + + + +
- - Ranges mgmtsystem.kpi.threshold.range @@ -152,6 +158,13 @@ + + From cd091d8f9a5aad1d550b2d9b794a7ca0e57de405 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Tue, 31 Jul 2012 18:16:20 -0400 Subject: [PATCH 03/40] [IMP] History --- mgmtsystem_kpi/mgmtsystem_kpi.py | 32 +++++++++++++++++++++++++++++-- mgmtsystem_kpi/mgmtsystem_kpi.xml | 17 ++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/mgmtsystem_kpi/mgmtsystem_kpi.py b/mgmtsystem_kpi/mgmtsystem_kpi.py index fdfac289c..5fe5d8c23 100644 --- a/mgmtsystem_kpi/mgmtsystem_kpi.py +++ b/mgmtsystem_kpi/mgmtsystem_kpi.py @@ -20,6 +20,7 @@ ############################################################################## from osv import fields, osv +import time class mgmtsystem_kpi_category(osv.osv): """ @@ -93,6 +94,27 @@ class mgmtsystem_kpi_periodicity_uom(osv.osv): mgmtsystem_kpi_threshold() +class mgmtsystem_kpi_history(osv.osv): + """ + History of the KPI + """ + _name = "mgmtsystem.kpi.history" + _description = "History of the KPI" + + _columns = { + 'name': fields.char('Name', size=150, required=True), + 'kpi_id': fields.many2one('mgmtsystem.kpi', 'KPI', required=True), + 'date': fields.datetime('Execution Date', required=True, readonly=True), + 'value': fields.float('Value', required=True, readonly=True), + } + + _defaults = { + 'name': lambda *a: time.strftime('%d %B %Y'), + 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), + } + +mgmtsystem_kpi_threshold() + class mgmtsystem_kpi(osv.osv): """ Key Performance Indicators @@ -100,8 +122,13 @@ class mgmtsystem_kpi(osv.osv): _name = "mgmtsystem.kpi" _description = "Key Performance Indicator" + def _display_last_kpi_value(self, cr, uid, ids, field_name, arg, context=None): + result = {} + + return result + def _compute_kpi_value(self, cr, uid, ids, field_name, arg, context=None): - result= {} + result = {} return result @@ -112,8 +139,9 @@ class mgmtsystem_kpi(osv.osv): 'threshold_id': fields.many2one('mgmtsystem.kpi.threshold','Threshold', required=True), 'periodicity': fields.integer('Periodicity'), 'periodicity_uom': fields.many2one('mgmtsystem.kpi.periodicity.uom','Periodicity UoM', required=True), - 'value': fields.function(_compute_kpi_value, string='Value', type='float'), + 'value': fields.function(_display_last_kpi_value, string='Value', type='float'), 'kpi_code': fields.text('KPI Computation Code'), + 'history_ids': fields.one2many('mgmtsystem.kpi.history', 'kpi_id', 'History') } mgmtsystem_kpi() diff --git a/mgmtsystem_kpi/mgmtsystem_kpi.xml b/mgmtsystem_kpi/mgmtsystem_kpi.xml index cf0086c6a..4ae37bd33 100644 --- a/mgmtsystem_kpi/mgmtsystem_kpi.xml +++ b/mgmtsystem_kpi/mgmtsystem_kpi.xml @@ -36,6 +36,8 @@ + + @@ -55,6 +57,21 @@ parent="mgmtsystem.menu_mgmtsystem_main" groups="base.group_user"/> + + + + mgmtsystem.kpi.history.tree + mgmtsystem.kpi.history + tree + + + + + + + + + From 172d137baa1fb5824e2c710d19caf084b43ca16e Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Tue, 31 Jul 2012 18:30:27 -0400 Subject: [PATCH 04/40] [IMP] View --- mgmtsystem_kpi/mgmtsystem_kpi.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mgmtsystem_kpi/mgmtsystem_kpi.xml b/mgmtsystem_kpi/mgmtsystem_kpi.xml index 4ae37bd33..0ef319aac 100644 --- a/mgmtsystem_kpi/mgmtsystem_kpi.xml +++ b/mgmtsystem_kpi/mgmtsystem_kpi.xml @@ -27,9 +27,11 @@ - + +