Browse Source

[IMP] History

pull/510/head^2
Maxime Chambreuil 13 years ago
parent
commit
cd091d8f9a
  1. 32
      mgmtsystem_kpi/mgmtsystem_kpi.py
  2. 17
      mgmtsystem_kpi/mgmtsystem_kpi.xml

32
mgmtsystem_kpi/mgmtsystem_kpi.py

@ -20,6 +20,7 @@
############################################################################## ##############################################################################
from osv import fields, osv from osv import fields, osv
import time
class mgmtsystem_kpi_category(osv.osv): class mgmtsystem_kpi_category(osv.osv):
""" """
@ -93,6 +94,27 @@ class mgmtsystem_kpi_periodicity_uom(osv.osv):
mgmtsystem_kpi_threshold() 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): class mgmtsystem_kpi(osv.osv):
""" """
Key Performance Indicators Key Performance Indicators
@ -100,8 +122,13 @@ class mgmtsystem_kpi(osv.osv):
_name = "mgmtsystem.kpi" _name = "mgmtsystem.kpi"
_description = "Key Performance Indicator" _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): def _compute_kpi_value(self, cr, uid, ids, field_name, arg, context=None):
result= {}
result = {}
return result return result
@ -112,8 +139,9 @@ class mgmtsystem_kpi(osv.osv):
'threshold_id': fields.many2one('mgmtsystem.kpi.threshold','Threshold', required=True), 'threshold_id': fields.many2one('mgmtsystem.kpi.threshold','Threshold', required=True),
'periodicity': fields.integer('Periodicity'), 'periodicity': fields.integer('Periodicity'),
'periodicity_uom': fields.many2one('mgmtsystem.kpi.periodicity.uom','Periodicity UoM', required=True), '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'), 'kpi_code': fields.text('KPI Computation Code'),
'history_ids': fields.one2many('mgmtsystem.kpi.history', 'kpi_id', 'History')
} }
mgmtsystem_kpi() mgmtsystem_kpi()

17
mgmtsystem_kpi/mgmtsystem_kpi.xml

@ -36,6 +36,8 @@
<field name="kpi_code" colspan="4"/> <field name="kpi_code" colspan="4"/>
<newline/> <newline/>
<field name="description" colspan="4"/> <field name="description" colspan="4"/>
<newline/>
<field name="history_ids" colspan="4"/>
</form> </form>
</field> </field>
</record> </record>
@ -55,6 +57,21 @@
parent="mgmtsystem.menu_mgmtsystem_main" parent="mgmtsystem.menu_mgmtsystem_main"
groups="base.group_user"/> groups="base.group_user"/>
<!-- KPI history -->
<record id="view_mgmtsystem_kpi_history_tree" model="ir.ui.view">
<field name="name">mgmtsystem.kpi.history.tree</field>
<field name="model">mgmtsystem.kpi.history</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="KPI History">
<field name="name"/>
<field name="date"/>
<field name="value"/>
</tree>
</field>
</record>
<!-- Thresholds --> <!-- Thresholds -->
<record id="view_mgmtsystem_kpi_threshold_tree" model="ir.ui.view"> <record id="view_mgmtsystem_kpi_threshold_tree" model="ir.ui.view">

Loading…
Cancel
Save