From ccb2889cac27c95475dbe421fa32711dd719c3bf Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Thu, 8 Sep 2022 16:04:08 +0530 Subject: [PATCH 1/2] fix: SCO Supplied Items returned-qty --- erpnext/controllers/subcontracting_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/controllers/subcontracting_controller.py b/erpnext/controllers/subcontracting_controller.py index 21504774f6..bbd950ed37 100644 --- a/erpnext/controllers/subcontracting_controller.py +++ b/erpnext/controllers/subcontracting_controller.py @@ -877,6 +877,7 @@ def make_return_stock_entry_for_subcontract( { order_doctype: { "doctype": "Stock Entry", + "field_no_map": ["purchase_order", "subcontracting_order"], }, }, ignore_child_tables=True, From aea71883040360b688de729cf20e9fc1b48a1800 Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Thu, 8 Sep 2022 17:02:37 +0530 Subject: [PATCH 2/2] test: add test case for returned-qty --- .../test_subcontracting_order.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py b/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py index 9385568c2b..d054ce0f9d 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py +++ b/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py @@ -502,6 +502,35 @@ class TestSubcontractingOrder(FrappeTestCase): set_backflush_based_on("BOM") + def test_get_materials_from_supplier(self): + # Create SCO + sco = get_subcontracting_order() + + # Transfer RM + rm_items = get_rm_items(sco.supplied_items) + itemwise_details = make_stock_in_entry(rm_items=rm_items) + make_stock_transfer_entry( + sco_no=sco.name, + rm_items=rm_items, + itemwise_details=copy.deepcopy(itemwise_details), + ) + + # Create SCR (Partial) + scr = make_subcontracting_receipt(sco.name) + scr.items[0].qty -= 5 + scr.save() + scr.submit() + + # Get RM from Supplier + ste = get_materials_from_supplier(sco.name, [d.name for d in sco.supplied_items]) + ste.save() + ste.submit() + + sco.load_from_db() + + self.assertEqual(sco.status, "Closed") + self.assertEqual(sco.supplied_items[0].returned_qty, 5) + def create_subcontracting_order(**args): args = frappe._dict(args)