From 42928f978b4160a09da715093312feeed35b8c0d Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Tue, 13 Nov 2018 11:04:17 +0530 Subject: [PATCH] fix: work order item sorting (#15967) --- erpnext/manufacturing/doctype/work_order/work_order.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index 1d465d57ae..e73328f10e 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -448,7 +448,9 @@ class WorkOrder(Document): if item_dict.get(d.item_code): d.required_qty = item_dict.get(d.item_code).get("qty") else: - for item in sorted(item_dict.values(), key=lambda d: d['idx']): + # Attribute a big number (999) to idx for sorting putpose in case idx is NULL + # For instance in BOM Explosion Item child table, the items coming from sub assembly items + for item in sorted(item_dict.values(), key=lambda d: d['idx'] or 9999): self.append('required_items', { 'operation': item.operation, 'item_code': item.item_code,