From 5b64ac9cdb9575e5377a4fd0c896aa1474ac50b9 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 20:33:16 +0530 Subject: [PATCH] fix: respect `null` as number value (#25639) Null is the intentional absence of a value. It represents a variable that has been explicitly set to have no value. (cherry picked from commit 8b0c20246c7c3ef65d52c9f6d1dfaf375490cba6) Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com> --- frappe/public/js/frappe/form/formatters.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frappe/public/js/frappe/form/formatters.js b/frappe/public/js/frappe/form/formatters.js index 8e98c1042cc..c068502fc7b 100644 --- a/frappe/public/js/frappe/form/formatters.js +++ b/frappe/public/js/frappe/form/formatters.js @@ -49,6 +49,10 @@ frappe.form.formatters = { return __(frappe.form.formatters["Data"](value, df)); }, Float: function (value, docfield, options, doc) { + if (value === null) { + return ""; + } + // don't allow 0 precision for Floats, hence or'ing with null var precision = docfield.precision || @@ -73,12 +77,20 @@ frappe.form.formatters = { } }, Int: function (value, docfield, options) { + if (value === null) { + return ""; + } + if (cstr(docfield.options).trim() === "File Size") { return frappe.form.formatters.FileSize(value); } return frappe.form.formatters._right(value == null ? "" : cint(value), options); }, Percent: function (value, docfield, options) { + if (value === null) { + return ""; + } + const precision = docfield.precision || cint(frappe.boot.sysdefaults && frappe.boot.sysdefaults.float_precision) || @@ -105,6 +117,10 @@ frappe.form.formatters = { `; }, Currency: function (value, docfield, options, doc) { + if (value === null) { + return ""; + } + var currency = frappe.meta.get_field_currency(docfield, doc); let precision;