fix: not able to make material request (#36416)
This commit is contained in:
parent
e8eeeb16e2
commit
f83a100a8d
@ -733,7 +733,7 @@ def make_material_request(source_name, target_doc=None):
|
|||||||
# qty is for packed items, because packed items don't have stock_qty field
|
# qty is for packed items, because packed items don't have stock_qty field
|
||||||
qty = source.get("qty")
|
qty = source.get("qty")
|
||||||
target.project = source_parent.project
|
target.project = source_parent.project
|
||||||
target.qty = qty - requested_item_qty.get(source.name, 0) - source.delivered_qty
|
target.qty = qty - requested_item_qty.get(source.name, 0) - flt(source.get("delivered_qty"))
|
||||||
target.stock_qty = flt(target.qty) * flt(target.conversion_factor)
|
target.stock_qty = flt(target.qty) * flt(target.conversion_factor)
|
||||||
|
|
||||||
args = target.as_dict().copy()
|
args = target.as_dict().copy()
|
||||||
@ -767,7 +767,7 @@ def make_material_request(source_name, target_doc=None):
|
|||||||
"doctype": "Material Request Item",
|
"doctype": "Material Request Item",
|
||||||
"field_map": {"name": "sales_order_item", "parent": "sales_order"},
|
"field_map": {"name": "sales_order_item", "parent": "sales_order"},
|
||||||
"condition": lambda doc: not frappe.db.exists("Product Bundle", doc.item_code)
|
"condition": lambda doc: not frappe.db.exists("Product Bundle", doc.item_code)
|
||||||
and (doc.stock_qty - doc.delivered_qty) > requested_item_qty.get(doc.name, 0),
|
and (doc.stock_qty - flt(doc.get("delivered_qty"))) > requested_item_qty.get(doc.name, 0),
|
||||||
"postprocess": update_item,
|
"postprocess": update_item,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -549,6 +549,26 @@ class TestSalesOrder(FrappeTestCase):
|
|||||||
workflow.is_active = 0
|
workflow.is_active = 0
|
||||||
workflow.save()
|
workflow.save()
|
||||||
|
|
||||||
|
def test_material_request_for_product_bundle(self):
|
||||||
|
# Create the Material Request from the sales order for the Packing Items
|
||||||
|
# Check whether the material request has the correct packing item or not.
|
||||||
|
if not frappe.db.exists("Item", "_Test Product Bundle Item New 1"):
|
||||||
|
bundle_item = make_item("_Test Product Bundle Item New 1", {"is_stock_item": 0})
|
||||||
|
bundle_item.append(
|
||||||
|
"item_defaults", {"company": "_Test Company", "default_warehouse": "_Test Warehouse - _TC"}
|
||||||
|
)
|
||||||
|
bundle_item.save(ignore_permissions=True)
|
||||||
|
|
||||||
|
make_item("_Packed Item New 2", {"is_stock_item": 1})
|
||||||
|
make_product_bundle("_Test Product Bundle Item New 1", ["_Packed Item New 2"], 2)
|
||||||
|
|
||||||
|
so = make_sales_order(
|
||||||
|
item_code="_Test Product Bundle Item New 1",
|
||||||
|
)
|
||||||
|
|
||||||
|
mr = make_material_request(so.name)
|
||||||
|
self.assertEqual(mr.items[0].item_code, "_Packed Item New 2")
|
||||||
|
|
||||||
def test_bin_details_of_packed_item(self):
|
def test_bin_details_of_packed_item(self):
|
||||||
# test Update Items with product bundle
|
# test Update Items with product bundle
|
||||||
if not frappe.db.exists("Item", "_Test Product Bundle Item New"):
|
if not frappe.db.exists("Item", "_Test Product Bundle Item New"):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user