mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-14 04:15:10 +00:00
Merge pull request #45270 from mihir-kandoi/st29053
fix: Skip WIP Warehouse transfer
This commit is contained in:
@@ -884,9 +884,9 @@ class TestProductionPlan(IntegrationTestCase):
|
||||
"""
|
||||
from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record
|
||||
|
||||
make_stock_entry(item_code="_Test Item", target="Work In Progress - _TC", qty=2, basic_rate=100)
|
||||
make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=2, basic_rate=100)
|
||||
make_stock_entry(
|
||||
item_code="_Test Item Home Desktop 100", target="Work In Progress - _TC", qty=4, basic_rate=100
|
||||
item_code="_Test Item Home Desktop 100", target="_Test Warehouse - _TC", qty=4, basic_rate=100
|
||||
)
|
||||
|
||||
item = "_Test FG Item"
|
||||
@@ -934,10 +934,10 @@ class TestProductionPlan(IntegrationTestCase):
|
||||
from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record
|
||||
|
||||
make_stock_entry(
|
||||
item_code="Raw Material Item 1", target="Work In Progress - _TC", qty=2, basic_rate=100
|
||||
item_code="Raw Material Item 1", target="_Test Warehouse - _TC", qty=2, basic_rate=100
|
||||
)
|
||||
make_stock_entry(
|
||||
item_code="Raw Material Item 2", target="Work In Progress - _TC", qty=2, basic_rate=100
|
||||
item_code="Raw Material Item 2", target="_Test Warehouse - _TC", qty=2, basic_rate=100
|
||||
)
|
||||
|
||||
pln = create_production_plan(item_code="Test Production Item 1", skip_getting_mr_items=True)
|
||||
|
||||
@@ -724,7 +724,12 @@ class TestWorkOrder(IntegrationTestCase):
|
||||
self.assertEqual(row.item_code, fg_item)
|
||||
|
||||
work_order = make_wo_order_test_record(
|
||||
item=fg_item, skip_transfer=True, planned_start_date=now(), qty=30, do_not_save=True
|
||||
item=fg_item,
|
||||
skip_transfer=True,
|
||||
planned_start_date=now(),
|
||||
qty=30,
|
||||
do_not_save=True,
|
||||
source_warehouse="_Test Warehouse - _TC",
|
||||
)
|
||||
work_order.batch_size = 10
|
||||
work_order.insert()
|
||||
@@ -941,11 +946,13 @@ class TestWorkOrder(IntegrationTestCase):
|
||||
wip_warehouse=wip_warehouse,
|
||||
qty=qty,
|
||||
skip_transfer=1,
|
||||
source_warehouse=wip_warehouse,
|
||||
stock_uom=fg_item_non_whole.stock_uom,
|
||||
)
|
||||
|
||||
se = frappe.get_doc(make_stock_entry(wo.name, "Material Transfer for Manufacture", qty))
|
||||
se.get("items")[0].s_warehouse = "Stores - _TC"
|
||||
se.get("items")[0].t_warehouse = wip_warehouse
|
||||
se.insert()
|
||||
se.submit()
|
||||
|
||||
@@ -2061,6 +2068,7 @@ class TestWorkOrder(IntegrationTestCase):
|
||||
bom_no=bom_doc.name,
|
||||
qty=1,
|
||||
skip_transfer=1,
|
||||
source_warehouse="_Test Warehouse - _TC",
|
||||
)
|
||||
|
||||
job_cards = frappe.get_all("Job Card", filters={"work_order": wo.name})
|
||||
@@ -2467,6 +2475,37 @@ class TestWorkOrder(IntegrationTestCase):
|
||||
|
||||
frappe.db.set_single_value("Manufacturing Settings", "validate_components_quantities_per_bom", 0)
|
||||
|
||||
def test_wip_skip(self):
|
||||
wo = make_wo_order_test_record(
|
||||
item="_Test FG Item",
|
||||
qty=10,
|
||||
source_warehouse="_Test Warehouse - _TC",
|
||||
wip_warehouse="Stores - _TC",
|
||||
)
|
||||
manufacture_entry = frappe.get_doc(make_stock_entry(wo.name, "Manufacture", 10))
|
||||
self.assertEqual(manufacture_entry.items[0].s_warehouse, "Stores - _TC")
|
||||
|
||||
wo = make_wo_order_test_record(
|
||||
item="_Test FG Item",
|
||||
qty=10,
|
||||
source_warehouse="_Test Warehouse - _TC",
|
||||
wip_warehouse="Stores - _TC",
|
||||
skip_transfer=1,
|
||||
)
|
||||
manufacture_entry = frappe.get_doc(make_stock_entry(wo.name, "Manufacture", 10))
|
||||
self.assertEqual(manufacture_entry.items[0].s_warehouse, "_Test Warehouse - _TC")
|
||||
|
||||
wo = make_wo_order_test_record(
|
||||
item="_Test FG Item",
|
||||
qty=10,
|
||||
source_warehouse="_Test Warehouse - _TC",
|
||||
wip_warehouse="Stores - _TC",
|
||||
skip_transfer=1,
|
||||
from_wip_warehouse=1,
|
||||
)
|
||||
manufacture_entry = frappe.get_doc(make_stock_entry(wo.name, "Manufacture", 10))
|
||||
self.assertEqual(manufacture_entry.items[0].s_warehouse, "Stores - _TC")
|
||||
|
||||
|
||||
def make_operation(**kwargs):
|
||||
kwargs = frappe._dict(kwargs)
|
||||
|
||||
@@ -170,6 +170,7 @@ class WorkOrder(Document):
|
||||
self.validate_sales_order()
|
||||
self.set_default_warehouse()
|
||||
self.validate_warehouse_belongs_to_company()
|
||||
self.check_wip_warehouse_skip()
|
||||
self.calculate_operating_cost()
|
||||
self.validate_qty()
|
||||
self.validate_transfer_against()
|
||||
@@ -269,6 +270,10 @@ class WorkOrder(Document):
|
||||
if not self.fg_warehouse:
|
||||
self.fg_warehouse = frappe.db.get_single_value("Manufacturing Settings", "default_fg_warehouse")
|
||||
|
||||
def check_wip_warehouse_skip(self):
|
||||
if self.skip_transfer and not self.from_wip_warehouse:
|
||||
self.wip_warehouse = None
|
||||
|
||||
def validate_warehouse_belongs_to_company(self):
|
||||
warehouses = [self.fg_warehouse, self.wip_warehouse]
|
||||
for d in self.get("required_items"):
|
||||
@@ -1460,7 +1465,11 @@ def make_stock_entry(work_order_id, purpose, qty=None, target_warehouse=None):
|
||||
stock_entry.to_warehouse = wip_warehouse
|
||||
stock_entry.project = work_order.project
|
||||
else:
|
||||
stock_entry.from_warehouse = wip_warehouse
|
||||
stock_entry.from_warehouse = (
|
||||
work_order.source_warehouse
|
||||
if work_order.skip_transfer and not work_order.from_wip_warehouse
|
||||
else wip_warehouse
|
||||
)
|
||||
stock_entry.to_warehouse = work_order.fg_warehouse
|
||||
stock_entry.project = work_order.project
|
||||
|
||||
|
||||
@@ -1712,13 +1712,13 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
wo.submit()
|
||||
make_stock_entry(
|
||||
item_code="_Test Item",
|
||||
target="Work In Progress - _TC",
|
||||
target="_Test Warehouse - _TC",
|
||||
qty=4,
|
||||
basic_rate=100, # Stock RM
|
||||
)
|
||||
make_stock_entry(
|
||||
item_code="_Test Item Home Desktop 100", # Stock RM
|
||||
target="Work In Progress - _TC",
|
||||
target="_Test Warehouse - _TC",
|
||||
qty=4,
|
||||
basic_rate=100,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user