Set fields in Item Variant Settings which should be copied from template to variant

This commit is contained in:
Nabin Hait 2017-09-21 15:41:15 +05:30
parent 5b05335e89
commit 2851dfad99
2 changed files with 8 additions and 4 deletions

View File

@ -4,11 +4,12 @@
frappe.ui.form.on('Item Variant Settings', {
setup: function(frm) {
const allow_fields = [];
const exclude_fields = ["item_code", "item_name", "show_in_website", "show_variant_in_website", "standard_rate"];
const exclude_fields = ["item_code", "item_name", "show_in_website", "show_variant_in_website",
"opening_stock", "variant_of", "valuation_rate", "variant_based_on"];
frappe.model.with_doctype('Item', () => {
frappe.get_meta('Item').fields.forEach(d => {
if(!in_list(['HTML', 'Section Break', 'Column Break', 'Button'], d.fieldtype)
if(!in_list(['HTML', 'Section Break', 'Column Break', 'Button', 'Read Only'], d.fieldtype)
&& !d.no_copy && !in_list(exclude_fields, d.fieldname)) {
allow_fields.push(d.fieldname);
}

View File

@ -10,11 +10,14 @@ class ItemVariantSettings(Document):
def set_default_fields(self):
self.fields = []
fields = frappe.get_meta('Item').fields
exclude_fields = ["item_code", "item_name", "show_in_website", "show_variant_in_website", "standard_rate"]
exclude_fields = ["item_code", "item_name", "show_in_website", "show_variant_in_website",
"standard_rate", "opening_stock", "image", "description",
"variant_of", "valuation_rate", "description", "variant_based_on",
"website_image", "thumbnail", "website_specifiations", "web_long_description"]
for d in fields:
if not d.no_copy and d.fieldname not in exclude_fields and \
d.fieldtype not in ['HTML', 'Section Break', 'Column Break', 'Button']:
d.fieldtype not in ['HTML', 'Section Break', 'Column Break', 'Button', 'Read Only']:
self.append('fields', {
'field_name': d.fieldname
})