Skip to content

Commit

Permalink
fix(ux): clean invalid fields from variant setting (frappe#27412)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Sep 12, 2021
1 parent a52d4c2 commit 6ef879f
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,32 @@
// For license information, please see license.txt

frappe.ui.form.on('Item Variant Settings', {
setup: function(frm) {
refresh: function(frm) {
const allow_fields = [];
const exclude_fields = ["naming_series", "item_code", "item_name", "show_in_website",
"show_variant_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.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)) {
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(
'field_name', 'options', allow_fields
);
Expand Down

0 comments on commit 6ef879f

Please sign in to comment.