feat: make Material Request for sub-assembly items
This commit is contained in:
parent
f6126069ee
commit
e02f35c8ff
@ -521,6 +521,9 @@ class ProductionPlan(Document):
|
|||||||
subcontracted_po.setdefault(row.supplier, []).append(row)
|
subcontracted_po.setdefault(row.supplier, []).append(row)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if row.type_of_manufacturing == "Material Request":
|
||||||
|
continue
|
||||||
|
|
||||||
work_order_data = {
|
work_order_data = {
|
||||||
"wip_warehouse": default_warehouses.get("wip_warehouse"),
|
"wip_warehouse": default_warehouses.get("wip_warehouse"),
|
||||||
"fg_warehouse": default_warehouses.get("fg_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)
|
subquery = frappe.qb.from_(wh).select(wh.name).where(wh.company == company)
|
||||||
|
|
||||||
|
warehouse = ""
|
||||||
if not all_warehouse:
|
if not all_warehouse:
|
||||||
warehouse = for_warehouse or row.get("source_warehouse") or row.get("default_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"] = []
|
doc["mr_items"] = []
|
||||||
|
|
||||||
po_items = doc.get("po_items") if doc.get("po_items") else doc.get("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
|
# 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")]:
|
if not po_items or not [row.get("item_code") for row in po_items if row.get("item_code")]:
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
|
@ -840,6 +840,34 @@ class TestProductionPlan(FrappeTestCase):
|
|||||||
self.assertEqual(row.uom, "Nos")
|
self.assertEqual(row.uom, "Nos")
|
||||||
self.assertEqual(row.qty, 1)
|
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):
|
def create_production_plan(**args):
|
||||||
"""
|
"""
|
||||||
|
@ -169,7 +169,7 @@
|
|||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Manufacturing Type",
|
"label": "Manufacturing Type",
|
||||||
"options": "In House\nSubcontract"
|
"options": "In House\nSubcontract\nMaterial Request"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "supplier",
|
"fieldname": "supplier",
|
||||||
@ -188,7 +188,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-01-30 21:31:10.527559",
|
"modified": "2022-11-28 13:50:15.116082",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Production Plan Sub Assembly Item",
|
"name": "Production Plan Sub Assembly Item",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user