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": {
"doctype": "Subcontracting Receipt",
"field_map": {"supplier_warehouse": "supplier_warehouse"},
"field_map": {
"supplier_warehouse": "supplier_warehouse",
"set_warehouse": "set_warehouse",
},
"validation": {
"docstatus": ["=", 1],
},

View File

@ -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:

View File

@ -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()

View File

@ -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])