From afdf1002d73951457affc0e8a4a2e0b8c84b38a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Tue, 5 May 2015 15:23:39 +0200 Subject: [PATCH] [IMP] mis_buidler: avoid non-sense % comparisons with base value close to 0 --- mis_builder/models/mis_builder.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mis_builder/models/mis_builder.py b/mis_builder/models/mis_builder.py index 3ccc168d..45cdd419 100644 --- a/mis_builder/models/mis_builder.py +++ b/mis_builder/models/mis_builder.py @@ -196,12 +196,13 @@ class mis_report_kpi(orm.Model): kpi.divider, kpi.dp, kpi.suffix, sign='+', context=context) - elif kpi.compare_method == 'pct' and base_value != 0: - return self._render_num(cr, uid, lang_id, - value / base_value - 1, - 0.01, kpi.dp, - '%', sign='+', - context=context) + elif kpi.compare_method == 'pct': + if round(base_value, kpi.dp) != 0: + return self._render_num(cr, uid, lang_id, + value / base_value - 1, + 0.01, kpi.dp, + '%', sign='+', + context=context) return '' def _render_num(self, cr, uid, lang_id, value, divider,