From 592c7b5ff123f99376cfc87915e9773da7dc9b7c Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Mon, 28 Aug 2023 00:08:05 +0530 Subject: [PATCH] fix: test cases --- .../doctype/subcontracting_order/subcontracting_order.py | 5 ++++- .../subcontracting_order/test_subcontracting_order.py | 7 +++++++ .../subcontracting_receipt/subcontracting_receipt.py | 2 +- .../subcontracting_receipt/test_subcontracting_receipt.py | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py index 0b14d4d9f5..b7b344584c 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py +++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py @@ -203,7 +203,10 @@ def get_mapped_subcontracting_receipt(source_name, target_doc=None): { "Subcontracting Order": { "doctype": "Subcontracting Receipt", - "field_map": {"supplier_warehouse": "supplier_warehouse"}, + "field_map": { + "supplier_warehouse": "supplier_warehouse", + "set_warehouse": "set_warehouse", + }, "validation": { "docstatus": ["=", 1], }, diff --git a/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py b/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py index 6a2983faaa..22fdc13cc1 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py +++ b/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py @@ -591,6 +591,13 @@ def create_subcontracting_order(**args): for idx, val in enumerate(sco.items): val.warehouse = warehouses[idx] + warehouses = set() + for item in sco.items: + warehouses.add(item.warehouse) + + if len(warehouses) == 1: + sco.set_warehouse = list(warehouses)[0] + if not args.do_not_save: sco.insert() if not args.do_not_submit: diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py index c601ddb999..c0a567d7a6 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py @@ -55,7 +55,7 @@ class SubcontractingReceipt(SubcontractingController): super(SubcontractingReceipt, self).validate() - if self.is_new() and self.get("_action") == "save": + if self.is_new() and self.get("_action") == "save" and not frappe.flags.in_test: self.get_scrap_items() self.set_missing_values() diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py index 0c163916b3..1828f6960f 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py @@ -686,6 +686,7 @@ class TestSubcontractingReceipt(FrappeTestCase): # Create Subcontracting Receipt scr = make_subcontracting_receipt(sco.name) scr.save() + scr.get_scrap_items() # Test - 1: Scrap Items should be fetched from BOM in items table with `is_scrap_item` = 1 scr_scrap_items = set([item.item_code for item in scr.items if item.is_scrap_item])