mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-24 05:47:15 +00:00
fix(manufacturing): finish a work order after partial material consumption (#59311)
This commit is contained in:
@@ -1430,6 +1430,9 @@ class StockEntry(StockController):
|
||||
if any(d.s_warehouse for d in self.get("items")):
|
||||
return True
|
||||
|
||||
return self.is_rm_cost_from_consumption_entries()
|
||||
|
||||
def is_rm_cost_from_consumption_entries(self) -> bool:
|
||||
settings = frappe.get_single("Manufacturing Settings")
|
||||
if settings.material_consumption and settings.get_rm_cost_from_consumption_entry and self.work_order:
|
||||
return bool(self.get_consumption_entries())
|
||||
@@ -2583,6 +2586,9 @@ class StockEntry(StockController):
|
||||
item["to_warehouse"] = self.pro_doc.wip_warehouse
|
||||
self.add_to_stock_entry_detail(item_dict)
|
||||
|
||||
elif self.purpose == "Manufacture" and self.is_rm_cost_from_consumption_entries():
|
||||
pass
|
||||
|
||||
elif (
|
||||
self.work_order
|
||||
and (
|
||||
|
||||
@@ -3055,6 +3055,33 @@ class TestStockEntry(FrappeTestCase):
|
||||
self.assertEqual(fg_row.basic_rate, 0)
|
||||
self.assertEqual(fg_row.basic_amount, 0)
|
||||
|
||||
@change_settings(
|
||||
"Manufacturing Settings", {"material_consumption": 1, "get_rm_cost_from_consumption_entry": 1}
|
||||
)
|
||||
def test_manufacture_after_partial_consumption_entry(self):
|
||||
from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom
|
||||
from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record
|
||||
from erpnext.manufacturing.doctype.work_order.work_order import (
|
||||
make_stock_entry as make_stock_entry_from_wo,
|
||||
)
|
||||
|
||||
rm_item = make_item(properties={"is_stock_item": 1}).name
|
||||
fg_item = make_item(properties={"is_stock_item": 1}).name
|
||||
make_stock_entry(item_code=rm_item, target="Stores - _TC", qty=10, basic_rate=100)
|
||||
bom = make_bom(item=fg_item, raw_materials=[rm_item], rm_qty=1).name
|
||||
|
||||
wo = make_wo_order_test_record(
|
||||
production_item=fg_item, bom_no=bom, qty=10, source_warehouse="Stores - _TC"
|
||||
)
|
||||
frappe.get_doc(make_stock_entry_from_wo(wo.name, "Material Transfer for Manufacture", 10)).submit()
|
||||
frappe.get_doc(make_stock_entry_from_wo(wo.name, "Material Consumption for Manufacture", 6)).submit()
|
||||
|
||||
manufacture = frappe.get_doc(make_stock_entry_from_wo(wo.name, "Manufacture", 10))
|
||||
manufacture.submit()
|
||||
|
||||
self.assertEqual([(d.item_code, d.basic_amount) for d in manufacture.items], [(fg_item, 600)])
|
||||
self.assertEqual(frappe.db.get_value("Work Order", wo.name, "status"), "Completed")
|
||||
|
||||
def test_disassemble_entry_without_wo(self):
|
||||
from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom
|
||||
|
||||
|
||||
Reference in New Issue
Block a user