fix: show ID field only when its for export and in import if naming series is Set by User

This commit is contained in:
Sumit Jain 2026-04-08 17:57:46 +05:30
parent ee32129517
commit fe1019f7cc

View file

@ -1,9 +1,10 @@
frappe.provide("frappe.data_import");
frappe.data_import.DataExporter = class DataExporter {
constructor(doctype, exporting_for, filetype = "CSV") {
constructor(doctype, exporting_for, filetype = "CSV", hide_blank_template = false) {
this.doctype = doctype;
this.exporting_for = exporting_for;
this.hide_blank_template = hide_blank_template;
frappe.model.with_doctype(doctype, () => {
this.make_dialog(filetype);
});
@ -37,13 +38,20 @@ frappe.data_import.DataExporter = class DataExporter {
label: __("5 Records"),
value: "5_records",
},
{
label: __("Blank Template"),
value: "blank_template",
},
],
].concat(
this.hide_blank_template
? []
: [
{
label: __("Blank Template"),
value: "blank_template",
},
]
),
default:
this.exporting_for === "Insert New Records" ? "blank_template" : "all",
this.exporting_for === "Insert New Records" && !this.hide_blank_template
? "blank_template"
: "all",
change: () => {
this.update_record_count_message();
},
@ -189,7 +197,7 @@ frappe.data_import.DataExporter = class DataExporter {
...multicheck_fields.map((fieldname) => {
let field = this.dialog.get_field(fieldname);
return field.options
.filter((option) => option.danger)
.filter((option) => option.danger || option.include_in_import_template)
.map((option) => option.$checkbox.find("input").get(0));
})
);
@ -274,6 +282,10 @@ frappe.data_import.DataExporter = class DataExporter {
let fieldname = meta.autoname.slice("field:".length);
autoname_field = frappe.meta.get_field(doctype, fieldname);
}
const hide_name_for_insert_when_not_set_by_user =
this.exporting_for === "Insert New Records" &&
!this.hide_blank_template &&
!["Prompt", "prompt"].includes(meta.autoname);
let fields = child_fieldname ? this.column_map[child_fieldname] : this.column_map[doctype];
@ -305,7 +317,11 @@ frappe.data_import.DataExporter = class DataExporter {
return fields
.filter((df) => {
if (autoname_field && df.fieldname === "name") {
if (
this.exporting_for === "Insert New Records" &&
(autoname_field || hide_name_for_insert_when_not_set_by_user) &&
df.fieldname === "name"
) {
return false;
}
return true;
@ -316,6 +332,7 @@ frappe.data_import.DataExporter = class DataExporter {
value: df.fieldname,
danger: is_field_mandatory(df),
warning: is_field_depends_on(df),
include_in_import_template: !!df.include_in_import_template,
checked: false,
description: `${df.fieldname} ${df.reqd ? __("(Mandatory)") : ""}`,
};