Code Fixes in Manage Variants
This commit is contained in:
parent
bd9745ba72
commit
fed431f908
@ -27,12 +27,7 @@ frappe.ui.form.on("Manage Variants", {
|
|||||||
select: function(event, ui) {
|
select: function(event, ui) {
|
||||||
field.$input.val(ui.item.value);
|
field.$input.val(ui.item.value);
|
||||||
field.$input.trigger("change");
|
field.$input.trigger("change");
|
||||||
},
|
|
||||||
focus: function( event, ui ) {
|
|
||||||
if(ui.manage_variants.action) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -125,7 +125,7 @@ class ManageVariants(Document):
|
|||||||
def sync_variants(self):
|
def sync_variants(self):
|
||||||
variant_item_codes = []
|
variant_item_codes = []
|
||||||
item_variants_attributes = {}
|
item_variants_attributes = {}
|
||||||
inserted, updated, renamed_old, renamed_new, deleted = [], [], [], [], []
|
inserted, updated, old_variant_name, new_variant_name, deleted = [], [], [], [], []
|
||||||
|
|
||||||
for v in self.variants:
|
for v in self.variants:
|
||||||
variant_item_codes.append(v.variant)
|
variant_item_codes.append(v.variant)
|
||||||
@ -146,16 +146,16 @@ class ManageVariants(Document):
|
|||||||
if sorted(json.loads(variant.attributes) ,key=lambda x: x[0]) == \
|
if sorted(json.loads(variant.attributes) ,key=lambda x: x[0]) == \
|
||||||
sorted(att ,key=lambda x: x[0]):
|
sorted(att ,key=lambda x: x[0]):
|
||||||
rename_variant(existing_variant, variant.variant)
|
rename_variant(existing_variant, variant.variant)
|
||||||
renamed_old.append(existing_variant)
|
old_variant_name.append(existing_variant)
|
||||||
renamed_new.append(variant.variant)
|
new_variant_name.append(variant.variant)
|
||||||
|
|
||||||
if existing_variant not in renamed_old:
|
if existing_variant not in old_variant_name:
|
||||||
delete_variant(existing_variant)
|
delete_variant(existing_variant)
|
||||||
deleted.append(existing_variant)
|
deleted.append(existing_variant)
|
||||||
|
|
||||||
for item_code in variant_item_codes:
|
for item_code in variant_item_codes:
|
||||||
if item_code not in existing_variants:
|
if item_code not in existing_variants:
|
||||||
if item_code not in renamed_new:
|
if item_code not in new_variant_name:
|
||||||
make_variant(self.item, item_code, self.variants)
|
make_variant(self.item, item_code, self.variants)
|
||||||
inserted.append(item_code)
|
inserted.append(item_code)
|
||||||
else:
|
else:
|
||||||
@ -168,8 +168,8 @@ class ManageVariants(Document):
|
|||||||
if updated:
|
if updated:
|
||||||
frappe.msgprint(_("Item Variants {0} updated").format(", ".join(updated)))
|
frappe.msgprint(_("Item Variants {0} updated").format(", ".join(updated)))
|
||||||
|
|
||||||
if renamed_old:
|
if old_variant_name:
|
||||||
frappe.msgprint(_("Item Variants {0} renamed").format(", ".join(renamed_old)))
|
frappe.msgprint(_("Item Variants {0} renamed").format(", ".join(old_variant_name)))
|
||||||
|
|
||||||
if deleted:
|
if deleted:
|
||||||
frappe.msgprint(_("Item Variants {0} deleted").format(", ".join(deleted)))
|
frappe.msgprint(_("Item Variants {0} deleted").format(", ".join(deleted)))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user