fix: do not make MR against raw materials of available sub assemblies (backport #40085) (#40087)

fix: do not make MR against raw materials of available sub assemblies (#40085)

(cherry picked from commit 4c9048fb3960668edd63a6e716b26d2e444bc1f9)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
mergify[bot] 2024-02-24 21:02:17 +05:30 committed by GitHub
parent 53d943ec70
commit cf5fa210bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 13 deletions

View File

@ -1507,19 +1507,17 @@ def get_items_for_material_requests(doc, warehouses=None, get_parent_warehouse_d
frappe.throw(_("For row {0}: Enter Planned Qty").format(data.get("idx")))
if bom_no:
if (
data.get("include_exploded_items")
and doc.get("sub_assembly_items")
and doc.get("skip_available_sub_assembly_item")
):
item_details = get_raw_materials_of_sub_assembly_items(
item_details,
company,
bom_no,
include_non_stock_items,
sub_assembly_items,
planned_qty=planned_qty,
)
if data.get("include_exploded_items") and doc.get("skip_available_sub_assembly_item"):
item_details = {}
if doc.get("sub_assembly_items"):
item_details = get_raw_materials_of_sub_assembly_items(
item_details,
company,
bom_no,
include_non_stock_items,
sub_assembly_items,
planned_qty=planned_qty,
)
elif data.get("include_exploded_items") and include_subcontracted_items:
# fetch exploded items from BOM

View File

@ -1232,6 +1232,35 @@ class TestProductionPlan(FrappeTestCase):
if row.item_code == "SubAssembly2 For SUB Test":
self.assertEqual(row.quantity, 10)
def test_sub_assembly_and_their_raw_materials_exists(self):
from erpnext.manufacturing.doctype.bom.test_bom import create_nested_bom
bom_tree = {
"FG1 For SUB Test": {
"SAB1 For SUB Test": {"CP1 For SUB Test": {}},
"SAB2 For SUB Test": {},
}
}
parent_bom = create_nested_bom(bom_tree, prefix="")
for item in ["SAB1 For SUB Test", "SAB2 For SUB Test"]:
make_stock_entry(item_code=item, qty=10, rate=100, target="_Test Warehouse - _TC")
plan = create_production_plan(
item_code=parent_bom.item,
planned_qty=10,
ignore_existing_ordered_qty=1,
do_not_submit=1,
skip_available_sub_assembly_item=1,
warehouse="_Test Warehouse - _TC",
)
items = get_items_for_material_requests(
plan.as_dict(), warehouses=[{"warehouse": "_Test Warehouse - _TC"}]
)
self.assertFalse(items)
def test_transfer_and_purchase_mrp_for_purchase_uom(self):
from erpnext.manufacturing.doctype.bom.test_bom import create_nested_bom
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse