mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 23:19:20 +00:00
fix(ux): clean invalid fields from variant setting (#27442)
* fix(ux): clean invalid fields from variant setting (#27412)
(cherry picked from commit 6ef879fca2)
# Conflicts:
# erpnext/stock/doctype/item_variant_settings/item_variant_settings.js
* fix: resolve conflicts
Co-authored-by: Ankush Menat <ankush@iwebnotes.com>
This commit is contained in:
@@ -2,19 +2,32 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('Item Variant Settings', {
|
frappe.ui.form.on('Item Variant Settings', {
|
||||||
setup: function(frm) {
|
refresh: function(frm) {
|
||||||
const allow_fields = [];
|
const allow_fields = [];
|
||||||
const exclude_fields = ["naming_series", "item_code", "item_name", "published_in_website",
|
|
||||||
"opening_stock", "variant_of", "valuation_rate"];
|
const existing_fields = frm.doc.fields.map(row => row.field_name);
|
||||||
|
const exclude_fields = [...existing_fields, "naming_series", "item_code", "item_name",
|
||||||
|
"show_in_website", "show_variant_in_website", "standard_rate", "opening_stock", "image",
|
||||||
|
"variant_of", "valuation_rate", "barcodes", "website_image", "thumbnail",
|
||||||
|
"website_specifiations", "web_long_description", "has_variants", "attributes"];
|
||||||
|
|
||||||
|
const exclude_field_types = ['HTML', 'Section Break', 'Column Break', 'Button', 'Read Only'];
|
||||||
|
|
||||||
frappe.model.with_doctype('Item', () => {
|
frappe.model.with_doctype('Item', () => {
|
||||||
frappe.get_meta('Item').fields.forEach(d => {
|
frappe.get_meta('Item').fields.forEach(d => {
|
||||||
if(!in_list(['HTML', 'Section Break', 'Column Break', 'Button', 'Read Only'], d.fieldtype)
|
if (!in_list(exclude_field_types, d.fieldtype)
|
||||||
&& !d.no_copy && !in_list(exclude_fields, d.fieldname)) {
|
&& !d.no_copy && !in_list(exclude_fields, d.fieldname)) {
|
||||||
allow_fields.push(d.fieldname);
|
allow_fields.push(d.fieldname);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (allow_fields.length == 0) {
|
||||||
|
allow_fields.push({
|
||||||
|
label: __("No additional fields available"),
|
||||||
|
value: "",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
frm.fields_dict.fields.grid.update_docfield_property(
|
frm.fields_dict.fields.grid.update_docfield_property(
|
||||||
'field_name', 'options', allow_fields
|
'field_name', 'options', allow_fields
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user