Merge pull request #33135 from rohitwaghchaure/feat-provision-to-make-mr-for-sub-assembly-items
feat: make Material Request for sub-assembly items
This commit is contained in:
commit
b8b9d1b0a8
@ -521,6 +521,9 @@ class ProductionPlan(Document):
|
||||
subcontracted_po.setdefault(row.supplier, []).append(row)
|
||||
continue
|
||||
|
||||
if row.type_of_manufacturing == "Material Request":
|
||||
continue
|
||||
|
||||
work_order_data = {
|
||||
"wip_warehouse": default_warehouses.get("wip_warehouse"),
|
||||
"fg_warehouse": default_warehouses.get("fg_warehouse"),
|
||||
@ -1161,6 +1164,7 @@ def get_bin_details(row, company, for_warehouse=None, all_warehouse=False):
|
||||
|
||||
subquery = frappe.qb.from_(wh).select(wh.name).where(wh.company == company)
|
||||
|
||||
warehouse = ""
|
||||
if not all_warehouse:
|
||||
warehouse = for_warehouse or row.get("source_warehouse") or row.get("default_warehouse")
|
||||
|
||||
@ -1226,6 +1230,21 @@ def get_items_for_material_requests(doc, warehouses=None, get_parent_warehouse_d
|
||||
doc["mr_items"] = []
|
||||
|
||||
po_items = doc.get("po_items") if doc.get("po_items") else doc.get("items")
|
||||
|
||||
if doc.get("sub_assembly_items"):
|
||||
for sa_row in doc.sub_assembly_items:
|
||||
sa_row = frappe._dict(sa_row)
|
||||
if sa_row.type_of_manufacturing == "Material Request":
|
||||
po_items.append(
|
||||
frappe._dict(
|
||||
{
|
||||
"item_code": sa_row.production_item,
|
||||
"required_qty": sa_row.qty,
|
||||
"include_exploded_items": 0,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
# Check for empty table or empty rows
|
||||
if not po_items or not [row.get("item_code") for row in po_items if row.get("item_code")]:
|
||||
frappe.throw(
|
||||
|
@ -840,6 +840,34 @@ class TestProductionPlan(FrappeTestCase):
|
||||
self.assertEqual(row.uom, "Nos")
|
||||
self.assertEqual(row.qty, 1)
|
||||
|
||||
def test_material_request_for_sub_assembly_items(self):
|
||||
from erpnext.manufacturing.doctype.bom.test_bom import create_nested_bom
|
||||
|
||||
bom_tree = {
|
||||
"Fininshed Goods1 For MR": {
|
||||
"SubAssembly1 For MR": {"SubAssembly1-1 For MR": {"ChildPart1 For MR": {}}}
|
||||
}
|
||||
}
|
||||
|
||||
parent_bom = create_nested_bom(bom_tree, prefix="")
|
||||
plan = create_production_plan(
|
||||
item_code=parent_bom.item, planned_qty=10, ignore_existing_ordered_qty=1, do_not_submit=1
|
||||
)
|
||||
|
||||
plan.get_sub_assembly_items()
|
||||
|
||||
mr_items = []
|
||||
for row in plan.sub_assembly_items:
|
||||
mr_items.append(row.production_item)
|
||||
row.type_of_manufacturing = "Material Request"
|
||||
|
||||
plan.save()
|
||||
items = get_items_for_material_requests(plan.as_dict())
|
||||
|
||||
validate_mr_items = [d.get("item_code") for d in items]
|
||||
for item_code in mr_items:
|
||||
self.assertTrue(item_code in validate_mr_items)
|
||||
|
||||
|
||||
def create_production_plan(**args):
|
||||
"""
|
||||
|
@ -169,7 +169,7 @@
|
||||
"fieldtype": "Select",
|
||||
"in_list_view": 1,
|
||||
"label": "Manufacturing Type",
|
||||
"options": "In House\nSubcontract"
|
||||
"options": "In House\nSubcontract\nMaterial Request"
|
||||
},
|
||||
{
|
||||
"fieldname": "supplier",
|
||||
@ -188,7 +188,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2022-01-30 21:31:10.527559",
|
||||
"modified": "2022-11-28 13:50:15.116082",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Production Plan Sub Assembly Item",
|
||||
|
Loading…
Reference in New Issue
Block a user