From fa858c76d3e84c4319f64533020711d23535fce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20=C4=90=E1=BA=A1i=20D=C6=B0=C6=A1ng?= Date: Tue, 17 Sep 2024 14:19:46 +0700 Subject: [PATCH] [FIX] hr_expense: correct monetary value on expense dashboard * Before this commit: the monetary value is always fix with 2 decimal and no thousand separator at all like 1000000 instead of 1.000.000 * After this commit correctly display thousand separator and of course the decimal and currency symbol simply using formatMonetary method closes odoo/odoo#180388 Signed-off-by: Antoine Dupuis (andu) --- .../static/src/components/expense_dashboard.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/addons/hr_expense/static/src/components/expense_dashboard.js b/addons/hr_expense/static/src/components/expense_dashboard.js index f536b6346d03e..04c99c28e35c6 100644 --- a/addons/hr_expense/static/src/components/expense_dashboard.js +++ b/addons/hr_expense/static/src/components/expense_dashboard.js @@ -1,7 +1,7 @@ /** @odoo-module */ import { useService } from '@web/core/utils/hooks'; -import session from 'web.session'; +import { formatMonetary } from "@web/views/fields/formatters"; const { Component, onWillStart, useState } = owl; @@ -22,16 +22,7 @@ export class ExpenseDashboard extends Component { } renderMonetaryField(value, currency_id) { - value = value.toFixed(2); - const currency = session.get_currency(currency_id); - if (currency) { - if (currency.position === "after") { - value += currency.symbol; - } else { - value = currency.symbol + value; - } - } - return value; + return formatMonetary(value, { currencyId: currency_id});; } } ExpenseDashboard.template = 'hr_expense.ExpenseDashboard';