Browse Source

Add a default style on kpi, and combine it with the kpi style computed

pull/90/head
Laetitia Gangloff 10 years ago
committed by Stéphane Bidoul
parent
commit
addc3f34c3
  1. 10
      mis_builder/models/mis_builder.py
  2. 4
      mis_builder/static/src/xml/mis_widget.xml
  3. 1
      mis_builder/views/mis_builder.xml

10
mis_builder/models/mis_builder.py

@ -132,6 +132,8 @@ class mis_report_kpi(orm.Model):
translate=True),
'expression': fields.char(required=True,
string='Expression'),
'default_css_style': fields.char(
string='Default CSS style expression'),
'css_style': fields.char(string='CSS style expression'),
'type': fields.selection([('num', _('Numeric')),
('pct', _('Percentage')),
@ -677,6 +679,7 @@ class mis_report_instance_period(orm.Model):
'val_r': kpi_val_rendered,
'val_c': kpi_val_comment,
'style': kpi_style,
'default_style': kpi.default_css_style or None,
'suffix': kpi.suffix,
'dp': kpi.dp,
'is_percentage': kpi.type == 'pct',
@ -788,11 +791,13 @@ class mis_report_instance(orm.Model):
content = OrderedDict()
# empty line name for header
header = OrderedDict()
header[''] = {'kpi_name': '', 'cols': []}
header[''] = {'kpi_name': '', 'cols': [], 'default_style': ''}
# initialize lines with kpi
for kpi in r.report_id.kpi_ids:
content[kpi.name] = {'kpi_name': kpi.description, 'cols': []}
content[kpi.name] = {'kpi_name': kpi.description,
'cols': [],
'default_style': ''}
report_instance_period_obj = self.pool.get(
'mis.report.instance.period')
@ -822,6 +827,7 @@ class mis_report_instance(orm.Model):
cr, uid, period, bal_vars, bals_vars, context=context)
period_values[period.name] = values
for key in values:
content[key]['default_style'] = values[key]['default_style']
content[key]['cols'].append(values[key])
# add comparison column

4
mis_builder/static/src/xml/mis_widget.xml

@ -19,13 +19,13 @@
</thead>
<tbody>
<tr t-foreach="widget.mis_report_data.content" t-as="c">
<th>
<th t-att="{'style': c_value.default_style}">
<div>
<t t-esc="c_value.kpi_name"/>
</div>
</th>
<t t-foreach="c_value.cols" t-as="value">
<td class="rallign" t-att="{'style': value_value.style}">
<td class="rallign" t-att="{'style': c_value.default_style + ';' + value_value.style}">
<label t-att="{'title': value_value.val_c}" class=" oe_form_label_help oe_align_right">
<t t-esc="value_value.val_r"/>
</label>

1
mis_builder/views/mis_builder.xml

@ -44,6 +44,7 @@
<field name="divider" attrs="{'invisible': [('type', '=', 'str')]}"/>
<field name="suffix"/>
<field name="compare_method" attrs="{'invisible': [('type', '=', 'str')]}"/>
<field name="default_css_style"/>
<field name="css_style"/>
</tree>
</field>

Loading…
Cancel
Save