Validation added to prevent user to Manage Variants if Item Template is Unsaved. Prevented message stating variants updated while saving item template if there are no variants against that item Template

This commit is contained in:
Neil Trini Lasrado 2015-07-23 12:46:59 +05:30
parent fec61fe33e
commit 13df8a40ef
2 changed files with 8 additions and 3 deletions

View File

@ -86,8 +86,12 @@ frappe.ui.form.on("Item", {
},
manage_variants: function(frm) {
frappe.route_options = {"item_code": frm.doc.name };
frappe.set_route("List", "Manage Variants");
if (cur_frm.doc.__unsaved==1) {
frappe.throw(__("You have unsaved changes. Please save."))
} else {
frappe.route_options = {"item_code": frm.doc.name };
frappe.set_route("List", "Manage Variants");
}
}
});

View File

@ -325,7 +325,8 @@ class Item(WebsiteGenerator):
for d in variants:
update_variant(self.name, d)
updated.append(d.item_code)
frappe.msgprint(_("Item Variants {0} updated").format(", ".join(updated)))
if updated:
frappe.msgprint(_("Item Variants {0} updated").format(", ".join(updated)))
def validate_has_variants(self):
if not self.has_variants and frappe.db.get_value("Item", self.name, "has_variants"):