From 0968118cfe213ba6db0c57953c5226986d2acdcb Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 29 Jan 2024 19:09:24 +0530 Subject: [PATCH] fix: not able to submit subcontracting pr (old flow) --- .../controllers/subcontracting_controller.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/erpnext/controllers/subcontracting_controller.py b/erpnext/controllers/subcontracting_controller.py index 9555902a74cd..f70104168339 100644 --- a/erpnext/controllers/subcontracting_controller.py +++ b/erpnext/controllers/subcontracting_controller.py @@ -260,18 +260,22 @@ def __get_received_items(self, doctype): return frappe.get_all(f"{doctype}", fields=fields, filters=filters) def __get_consumed_items(self, doctype, receipt_items): + fields = [ + "serial_no", + "rm_item_code", + "reference_name", + "batch_no", + "consumed_qty", + "main_item_code", + "parent as voucher_no", + ] + + if self.subcontract_data.receipt_supplied_items_field != "Purchase Receipt Item Supplied": + fields.append("serial_and_batch_bundle") + return frappe.get_all( self.subcontract_data.receipt_supplied_items_field, - fields=[ - "serial_no", - "rm_item_code", - "reference_name", - "serial_and_batch_bundle", - "batch_no", - "consumed_qty", - "main_item_code", - "parent as voucher_no", - ], + fields=fields, filters={"docstatus": 1, "reference_name": ("in", list(receipt_items)), "parenttype": doctype}, )