Merge pull request #11610 from prssanna/grid-upload

fix: convert float type fields from string to float in grid upload
This commit is contained in:
mergify[bot] 2020-10-12 05:43:40 +00:00 committed by GitHub
commit e16a49f496
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
});
}
}