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

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

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

1
mis_builder/views/mis_builder.xml

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

Loading…
Cancel
Save