diff --git a/erpnext/setup/doctype/item_group/item_group.js b/erpnext/setup/doctype/item_group/item_group.js index 46d403417d9..c55c7cbf129 100644 --- a/erpnext/setup/doctype/item_group/item_group.js +++ b/erpnext/setup/doctype/item_group/item_group.js @@ -20,7 +20,13 @@ frappe.ui.form.on("Item Group", { frm.trigger("set_root_readonly"); frm.add_custom_button(__("Item Group Tree"), function() { frappe.set_route("Tree", "Item Group"); - }, "icon-sitemap"); + }); + + if(!frm.is_new()) { + frm.add_custom_button(__("Items"), function() { + frappe.set_route("List", "Item", {"item_group": frm.doc.name}); + }); + } }, set_root_readonly: function(frm) { diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 5375db0b60e..12899cddd08 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -60,13 +60,15 @@ class ItemGroup(NestedSet, WebsiteGenerator): def get_context(self, context): context.show_search=True + context.page_length = 6 context.search_link = '/product_search' start = int(frappe.form_dict.start or 0) if start < 0: start = 0 context.update({ - "items": get_product_list_for_group(product_group = self.name, start=start, limit=24, search=frappe.form_dict.get("search")), + "items": get_product_list_for_group(product_group = self.name, start=start, + limit=context.page_length, search=frappe.form_dict.get("search")), "parent_groups": get_parent_item_groups(self.name), "title": self.name, "products_as_list": cint(frappe.db.get_single_value('Website Settings', 'products_as_list')) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index b546df4126f..454fc709816 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -455,16 +455,18 @@ class Item(WebsiteGenerator): def cant_change(self): if not self.get("__islocal"): - vals = frappe.db.get_value("Item", self.name, ["has_serial_no", "is_stock_item", - "valuation_method", "has_batch_no", "is_fixed_asset"], as_dict=True) + to_check = ("has_serial_no", "is_stock_item", + "valuation_method", "has_batch_no", "is_fixed_asset") - if vals and ((self.is_stock_item != vals.is_stock_item) or - vals.has_serial_no != self.has_serial_no or - vals.has_batch_no != self.has_batch_no or - cstr(vals.valuation_method) != cstr(self.valuation_method)): - if self.check_if_linked_document_exists(): - frappe.throw(_("As there are existing transactions for this item, \ - you can not change the values of 'Has Serial No', 'Has Batch No', 'Is Stock Item' and 'Valuation Method'")) + vals = frappe.db.get_value("Item", self.name, to_check, as_dict=True) + + if vals: + for key in to_check: + if self.get(key) != vals.get(key): + if not self.check_if_linked_document_exists(): + break # no linked document, allowed + else: + frappe.throw(_("As there are existing transactions for this item, you can not change the value of {0}").format(frappe.bold(self.meta.get_label(key)))) if vals and not self.is_fixed_asset and self.is_fixed_asset != vals.is_fixed_asset: asset = frappe.db.get_all("Asset", filters={"item_code": self.name, "docstatus": 1}, limit=1) diff --git a/erpnext/templates/generators/item_group.html b/erpnext/templates/generators/item_group.html index b9926d64331..674143d0872 100644 --- a/erpnext/templates/generators/item_group.html +++ b/erpnext/templates/generators/item_group.html @@ -31,10 +31,10 @@
{% else %}