From 05e13f456cdc2b849ee1739b22dd1bef77c0f406 Mon Sep 17 00:00:00 2001 From: "jerome hanke (jhk)" Date: Mon, 10 Feb 2020 13:45:52 +0000 Subject: [PATCH] [FIX] account: dashboard graphs proper float rounding Steps to reproduce: - install accounting - go to the accounting main view and hover some of the graphs Previous behavior: rounding was inconsistent and would lead to weird js floats like 65.00000000000001 Current behavior: floats are rounded to 2 digits after opw-2172686 closes odoo/odoo#45336 X-original-commit: c00f4962eb790787fffef99595ac14dbef026055 Signed-off-by: Nicolas Martinelli (nim) --- addons/account/models/account_journal_dashboard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py index 576bda8c8ca..43400afa408 100644 --- a/addons/account/models/account_journal_dashboard.py +++ b/addons/account/models/account_journal_dashboard.py @@ -84,6 +84,7 @@ class account_journal(models.Model): # Below method is used to get data of bank and cash statemens def get_line_graph_datas(self): """Computes the data used to display the graph for bank and cash journals in the accounting dashboard""" + currency = self.currency_id or self.company_id.currency_id def build_graph_data(date, amount): #display date in locale format @@ -123,7 +124,7 @@ class account_journal(models.Model): date = val['date'] if date != today.strftime(DF): # make sure the last point in the graph is today data[:0] = [build_graph_data(date, amount)] - amount -= val['amount'] + amount = currency.round(amount - val['amount']) # make sure the graph starts 1 month ago if date.strftime(DF) != last_month.strftime(DF):