mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-03 08:32:24 +00:00
fix(manufacturing): use item warehouses in production plan work orders (#58663)
(cherry picked from commit e74ab38eeb)
# Conflicts:
# erpnext/manufacturing/doctype/production_plan/services/work_order_planning.py
This commit is contained in:
@@ -929,8 +929,6 @@ class ProductionPlan(Document):
|
|||||||
|
|
||||||
wo = frappe.new_doc("Work Order")
|
wo = frappe.new_doc("Work Order")
|
||||||
wo.update(item)
|
wo.update(item)
|
||||||
if not wo.source_warehouse:
|
|
||||||
wo.source_warehouse = item.get("fg_warehouse")
|
|
||||||
|
|
||||||
wo.reserve_stock = self.reserve_stock
|
wo.reserve_stock = self.reserve_stock
|
||||||
wo.planned_start_date = item.get("planned_start_date") or item.get("schedule_date")
|
wo.planned_start_date = item.get("planned_start_date") or item.get("schedule_date")
|
||||||
@@ -939,7 +937,7 @@ class ProductionPlan(Document):
|
|||||||
wo.fg_warehouse = item.get("warehouse")
|
wo.fg_warehouse = item.get("warehouse")
|
||||||
|
|
||||||
wo.set_work_order_operations()
|
wo.set_work_order_operations()
|
||||||
wo.set_required_items(reset_source_warehouse=True)
|
wo.set_required_items()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
wo.flags.ignore_mandatory = True
|
wo.flags.ignore_mandatory = True
|
||||||
|
|||||||
@@ -128,6 +128,57 @@ class TestProductionPlan(ERPNextTestSuite):
|
|||||||
plan.reload()
|
plan.reload()
|
||||||
plan.cancel()
|
plan.cancel()
|
||||||
|
|
||||||
|
def test_subassembly_work_order_uses_raw_material_default_warehouses(self):
|
||||||
|
raw_material_warehouses = {
|
||||||
|
make_item(
|
||||||
|
properties={
|
||||||
|
"is_stock_item": 1,
|
||||||
|
"item_defaults": [
|
||||||
|
{"company": "_Test Company", "default_warehouse": "_Test Warehouse - _TC"}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
).name: "_Test Warehouse - _TC",
|
||||||
|
make_item(
|
||||||
|
properties={
|
||||||
|
"is_stock_item": 1,
|
||||||
|
"item_defaults": [
|
||||||
|
{"company": "_Test Company", "default_warehouse": "_Test Warehouse 1 - _TC"}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
).name: "_Test Warehouse 1 - _TC",
|
||||||
|
}
|
||||||
|
subassembly_item = make_item(properties={"is_stock_item": 1}).name
|
||||||
|
finished_item = make_item(properties={"is_stock_item": 1}).name
|
||||||
|
|
||||||
|
make_bom(item=subassembly_item, raw_materials=raw_material_warehouses)
|
||||||
|
make_bom(item=finished_item, raw_materials=[subassembly_item])
|
||||||
|
|
||||||
|
plan = create_production_plan(
|
||||||
|
item_code=finished_item,
|
||||||
|
warehouse="Finished Goods - _TC",
|
||||||
|
sub_assembly_warehouse="Finished Goods - _TC",
|
||||||
|
skip_available_sub_assembly_item=1,
|
||||||
|
skip_getting_mr_items=1,
|
||||||
|
do_not_submit=1,
|
||||||
|
)
|
||||||
|
plan.get_sub_assembly_items()
|
||||||
|
plan.save()
|
||||||
|
plan.submit()
|
||||||
|
plan.make_work_order()
|
||||||
|
|
||||||
|
work_order_name = frappe.db.get_value(
|
||||||
|
"Work Order",
|
||||||
|
{"production_plan": plan.name, "production_item": subassembly_item},
|
||||||
|
)
|
||||||
|
work_order = frappe.get_doc("Work Order", work_order_name)
|
||||||
|
|
||||||
|
self.assertFalse(work_order.source_warehouse)
|
||||||
|
self.assertEqual(work_order.fg_warehouse, plan.sub_assembly_warehouse)
|
||||||
|
self.assertEqual(
|
||||||
|
{row.item_code: row.source_warehouse for row in work_order.required_items},
|
||||||
|
raw_material_warehouses,
|
||||||
|
)
|
||||||
|
|
||||||
def test_production_plan_for_existing_ordered_qty(self):
|
def test_production_plan_for_existing_ordered_qty(self):
|
||||||
"""
|
"""
|
||||||
- Enable 'ignore_existing_ordered_qty'.
|
- Enable 'ignore_existing_ordered_qty'.
|
||||||
|
|||||||
Reference in New Issue
Block a user