diff --git a/frappe/public/js/frappe/form/grid.js b/frappe/public/js/frappe/form/grid.js index 401dac4a8a..394af9e3c6 100644 --- a/frappe/public/js/frappe/form/grid.js +++ b/frappe/public/js/frappe/form/grid.js @@ -763,6 +763,13 @@ export default class Grid { // download this.setup_download(); + const value_formatter_map = { + "Date": val => val ? frappe.datetime.user_to_str(val) : val, + "Int": val => cint(val), + "Check": val => cint(val), + "Float": val => flt(val), + }; + // upload frappe.flags.no_socketio = true; $(this.wrapper).find(".grid-upload").removeClass('hidden').on("click", () => { @@ -790,16 +797,9 @@ export default class Grid { var fieldname = fieldnames[ci]; var df = frappe.meta.get_docfield(me.df.options, fieldname); - // convert date formatting - if (df.fieldtype==="Date" && value) { - value = frappe.datetime.user_to_str(value); - } - - if (df.fieldtype==="Int" || df.fieldtype==="Check") { - value = cint(value); - } - - d[fieldnames[ci]] = value; + d[fieldnames[ci]] = value_formatter_map[df.fieldtype] + ? value_formatter_map[df.fieldtype](value) + : value; }); } }