From de5865753753942e24448f6211ad58ab8ebe95b6 Mon Sep 17 00:00:00 2001 From: alexandre-00 Date: Fri, 9 Jan 2015 14:20:43 +0800 Subject: [PATCH] Update bom.py Hi guys, Just a proposal to sort the Materials Required (Exploded) from the BOM. So the items and sub-assemblies items looks a little bit more organized in the list. Cheers Alexandre --- erpnext/manufacturing/doctype/bom/bom.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index bab1b43b60..c02576f86d 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -8,6 +8,8 @@ from frappe.utils import cint, cstr, flt from frappe import _ from frappe.model.document import Document +from operator import itemgetter, attrgetter + class BOM(Document): def autoname(self): @@ -360,7 +362,7 @@ class BOM(Document): "Add items to Flat BOM table" frappe.db.sql("""delete from `tabBOM Explosion Item` where parent=%s""", self.name) self.set('flat_bom_details', []) - for d in self.cur_exploded_items: + for d in sorted(self.cur_exploded_items, key=itemgetter(0)): ch = self.append('flat_bom_details', {}) for i in self.cur_exploded_items[d].keys(): ch.set(i, self.cur_exploded_items[d][i])