add a css style expression on kpi
parent
c047f52614
commit
d1a551a8c7
|
@ -84,6 +84,7 @@ class mis_report_kpi(orm.Model):
|
||||||
translate=True),
|
translate=True),
|
||||||
'expression': fields.char(required=True,
|
'expression': fields.char(required=True,
|
||||||
string='Expression'),
|
string='Expression'),
|
||||||
|
'css_style': fields.char(string='CSS style'),
|
||||||
'type': fields.selection([('num', _('Numeric')),
|
'type': fields.selection([('num', _('Numeric')),
|
||||||
('pct', _('Percentage')),
|
('pct', _('Percentage')),
|
||||||
('str', _('String'))],
|
('str', _('String'))],
|
||||||
|
@ -183,7 +184,7 @@ class mis_report_kpi(orm.Model):
|
||||||
def _render_num(self, value, divider, dp, suffix, sign='-'):
|
def _render_num(self, value, divider, dp, suffix, sign='-'):
|
||||||
divider_label = _get_selection_label(
|
divider_label = _get_selection_label(
|
||||||
self._columns['divider'].selection, divider)
|
self._columns['divider'].selection, divider)
|
||||||
fmt = '{:%s,.%df}%s%s' % (sign, dp, divider_label, suffix or '')
|
fmt = '{:%s,.%df}%s %s' % (sign, dp, divider_label, suffix or '')
|
||||||
value = round(value / float(divider or 1), dp) or 0
|
value = round(value / float(divider or 1), dp) or 0
|
||||||
return fmt.format(value)
|
return fmt.format(value)
|
||||||
|
|
||||||
|
@ -469,11 +470,18 @@ class mis_report_instance_period(orm.Model):
|
||||||
kpi_val_comment = None
|
kpi_val_comment = None
|
||||||
|
|
||||||
localdict[kpi.name] = kpi_val
|
localdict[kpi.name] = kpi_val
|
||||||
|
try:
|
||||||
|
kpi_style = None
|
||||||
|
if kpi.css_style:
|
||||||
|
kpi_style = safe_eval(kpi.css_style, localdict)
|
||||||
|
except:
|
||||||
|
kpi_style = None
|
||||||
|
|
||||||
res[kpi.name] = {
|
res[kpi.name] = {
|
||||||
'val': kpi_val,
|
'val': kpi_val,
|
||||||
'val_r': kpi_val_rendered,
|
'val_r': kpi_val_rendered,
|
||||||
'val_c': kpi_val_comment,
|
'val_c': kpi_val_comment,
|
||||||
|
'style': kpi_style,
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -24,11 +24,13 @@
|
||||||
<t t-esc="c_value.kpi_name"/>
|
<t t-esc="c_value.kpi_name"/>
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
<td t-foreach="c_value.cols" t-as="value" class="rallign">
|
<t t-foreach="c_value.cols" t-as="value">
|
||||||
<label t-att="{'title': value_value.val_c}" class=" oe_form_label_help oe_align_right">
|
<td class="rallign" t-att="{'style': value_value.style}">
|
||||||
<t t-esc="value_value.val_r"/>
|
<label t-att="{'title': value_value.val_c}" class=" oe_form_label_help oe_align_right">
|
||||||
</label>
|
<t t-esc="value_value.val_r"/>
|
||||||
</td>
|
</label>
|
||||||
|
</td>
|
||||||
|
</t>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
|
|
|
@ -43,6 +43,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="css_style"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
|
|
Loading…
Reference in New Issue