fix: test cases

This commit is contained in:
s-aga-r 2023-08-28 00:08:05 +05:30
parent ffcbcd7397
commit 592c7b5ff1
4 changed files with 13 additions and 2 deletions

View File

@ -203,7 +203,10 @@ def get_mapped_subcontracting_receipt(source_name, target_doc=None):
{ {
"Subcontracting Order": { "Subcontracting Order": {
"doctype": "Subcontracting Receipt", "doctype": "Subcontracting Receipt",
"field_map": {"supplier_warehouse": "supplier_warehouse"}, "field_map": {
"supplier_warehouse": "supplier_warehouse",
"set_warehouse": "set_warehouse",
},
"validation": { "validation": {
"docstatus": ["=", 1], "docstatus": ["=", 1],
}, },

View File

@ -591,6 +591,13 @@ def create_subcontracting_order(**args):
for idx, val in enumerate(sco.items): for idx, val in enumerate(sco.items):
val.warehouse = warehouses[idx] 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: if not args.do_not_save:
sco.insert() sco.insert()
if not args.do_not_submit: if not args.do_not_submit:

View File

@ -55,7 +55,7 @@ class SubcontractingReceipt(SubcontractingController):
super(SubcontractingReceipt, self).validate() 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.get_scrap_items()
self.set_missing_values() self.set_missing_values()

View File

@ -686,6 +686,7 @@ class TestSubcontractingReceipt(FrappeTestCase):
# Create Subcontracting Receipt # Create Subcontracting Receipt
scr = make_subcontracting_receipt(sco.name) scr = make_subcontracting_receipt(sco.name)
scr.save() scr.save()
scr.get_scrap_items()
# Test - 1: Scrap Items should be fetched from BOM in items table with `is_scrap_item` = 1 # 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]) scr_scrap_items = set([item.item_code for item in scr.items if item.is_scrap_item])