From addc3f34c312c611b94b165d392251fd44a79c35 Mon Sep 17 00:00:00 2001 From: Laetitia Gangloff Date: Tue, 23 Dec 2014 11:07:16 +0100 Subject: [PATCH] Add a default style on kpi, and combine it with the kpi style computed --- mis_builder/models/mis_builder.py | 10 ++++++++-- mis_builder/static/src/xml/mis_widget.xml | 4 ++-- mis_builder/views/mis_builder.xml | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mis_builder/models/mis_builder.py b/mis_builder/models/mis_builder.py index 8bea1923..f9111d29 100644 --- a/mis_builder/models/mis_builder.py +++ b/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 diff --git a/mis_builder/static/src/xml/mis_widget.xml b/mis_builder/static/src/xml/mis_widget.xml index 19d4869a..6ec2722d 100644 --- a/mis_builder/static/src/xml/mis_widget.xml +++ b/mis_builder/static/src/xml/mis_widget.xml @@ -19,13 +19,13 @@ - +
- + diff --git a/mis_builder/views/mis_builder.xml b/mis_builder/views/mis_builder.xml index 3afce7cb..bcfaa60b 100644 --- a/mis_builder/views/mis_builder.xml +++ b/mis_builder/views/mis_builder.xml @@ -44,6 +44,7 @@ +