Browse Source

[IMP] mis_builder: give a description to sub kpis

name is the python variable name, to be used (in the future)
to reference sub-kpi values in expressions.

description is the human-readable name to display in column
headers.
pull/189/head
Stéphane Bidoul 9 years ago
parent
commit
800cfda277
  1. 31
      mis_builder/models/mis_builder.py
  2. 1
      mis_builder/views/mis_builder.xml

31
mis_builder/models/mis_builder.py

@ -398,9 +398,36 @@ class MisReportSubkpi(models.Model):
sequence = fields.Integer()
report_id = fields.Many2one('mis.report')
name = fields.Char(required=True)
name = fields.Char(size=32, required=True,
string='Name')
description = fields.Char(required=True,
string='Description',
translate=True)
expression_ids = fields.One2many('mis.report.kpi.expression', 'subkpi_id')
@api.one
@api.constrains('name')
def _check_name(self):
if not _is_valid_python_var(self.name):
raise exceptions.Warning(_('The name must be a valid '
'python identifier'))
@api.onchange('name')
def _onchange_name(self):
if self.name and not _is_valid_python_var(self.name):
return {
'warning': {
'title': 'Invalid name %s' % self.name,
'message': 'The name must be a valid python identifier'
}
}
@api.onchange('description')
def _onchange_description(self):
""" construct name from description """
if self.description and not self.name:
self.name = _python_var(self.description)
@api.multi
def unlink(self):
for subkpi in self:
@ -1271,7 +1298,7 @@ class MisReportInstance(models.Model):
if subkpis:
for subkpi in subkpis:
header[1]['cols'].append(dict(
name=subkpi.name,
name=subkpi.description,
colspan=1,
))
else:

1
mis_builder/views/mis_builder.xml

@ -39,6 +39,7 @@
<field name="subkpi_ids" nolabel="1" colspan="2">
<tree string="Sub KPI's" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="description"/>
<field name="name"/>
</tree>
</field>

Loading…
Cancel
Save