mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 15:09:20 +00:00
Merge pull request #45274 from frappe/mergify/bp/version-15-hotfix/pr-45270
fix: Skip WIP Warehouse transfer (backport #45270)
This commit is contained in:
@@ -522,6 +522,7 @@ class TestJobCard(FrappeTestCase):
|
|||||||
production_item=item_code,
|
production_item=item_code,
|
||||||
bom_no=bom_doc.name,
|
bom_no=bom_doc.name,
|
||||||
skip_transfer=1,
|
skip_transfer=1,
|
||||||
|
from_wip_warehouse=1,
|
||||||
wip_warehouse=warehouse,
|
wip_warehouse=warehouse,
|
||||||
source_warehouse=warehouse,
|
source_warehouse=warehouse,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -744,9 +744,9 @@ class TestProductionPlan(FrappeTestCase):
|
|||||||
"""
|
"""
|
||||||
from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record
|
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(
|
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"
|
item = "_Test FG Item"
|
||||||
@@ -794,10 +794,10 @@ class TestProductionPlan(FrappeTestCase):
|
|||||||
from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record
|
from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record
|
||||||
|
|
||||||
make_stock_entry(
|
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(
|
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)
|
pln = create_production_plan(item_code="Test Production Item 1", skip_getting_mr_items=True)
|
||||||
|
|||||||
@@ -714,7 +714,12 @@ class TestWorkOrder(FrappeTestCase):
|
|||||||
self.assertEqual(row.item_code, fg_item)
|
self.assertEqual(row.item_code, fg_item)
|
||||||
|
|
||||||
work_order = make_wo_order_test_record(
|
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.batch_size = 10
|
||||||
work_order.insert()
|
work_order.insert()
|
||||||
@@ -931,11 +936,13 @@ class TestWorkOrder(FrappeTestCase):
|
|||||||
wip_warehouse=wip_warehouse,
|
wip_warehouse=wip_warehouse,
|
||||||
qty=qty,
|
qty=qty,
|
||||||
skip_transfer=1,
|
skip_transfer=1,
|
||||||
|
source_warehouse=wip_warehouse,
|
||||||
stock_uom=fg_item_non_whole.stock_uom,
|
stock_uom=fg_item_non_whole.stock_uom,
|
||||||
)
|
)
|
||||||
|
|
||||||
se = frappe.get_doc(make_stock_entry(wo.name, "Material Transfer for Manufacture", qty))
|
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].s_warehouse = "Stores - _TC"
|
||||||
|
se.get("items")[0].t_warehouse = wip_warehouse
|
||||||
se.insert()
|
se.insert()
|
||||||
se.submit()
|
se.submit()
|
||||||
|
|
||||||
@@ -1007,7 +1014,12 @@ class TestWorkOrder(FrappeTestCase):
|
|||||||
bom.submit()
|
bom.submit()
|
||||||
|
|
||||||
wo_order = make_wo_order_test_record(
|
wo_order = make_wo_order_test_record(
|
||||||
item=item, company=company, planned_start_date=now(), qty=20, skip_transfer=1
|
item=item,
|
||||||
|
company=company,
|
||||||
|
planned_start_date=now(),
|
||||||
|
qty=20,
|
||||||
|
skip_transfer=1,
|
||||||
|
from_wip_warehouse=1,
|
||||||
)
|
)
|
||||||
job_card = frappe.db.get_value("Job Card", {"work_order": wo_order.name}, "name")
|
job_card = frappe.db.get_value("Job Card", {"work_order": wo_order.name}, "name")
|
||||||
update_job_card(job_card)
|
update_job_card(job_card)
|
||||||
@@ -1019,7 +1031,12 @@ class TestWorkOrder(FrappeTestCase):
|
|||||||
|
|
||||||
# Partial Job Card 1 with qty 10
|
# Partial Job Card 1 with qty 10
|
||||||
wo_order = make_wo_order_test_record(
|
wo_order = make_wo_order_test_record(
|
||||||
item=item, company=company, planned_start_date=add_days(now(), 60), qty=20, skip_transfer=1
|
item=item,
|
||||||
|
company=company,
|
||||||
|
planned_start_date=add_days(now(), 60),
|
||||||
|
qty=20,
|
||||||
|
skip_transfer=1,
|
||||||
|
from_wip_warehouse=1,
|
||||||
)
|
)
|
||||||
job_card = frappe.db.get_value("Job Card", {"work_order": wo_order.name}, "name")
|
job_card = frappe.db.get_value("Job Card", {"work_order": wo_order.name}, "name")
|
||||||
update_job_card(job_card, 10, 1)
|
update_job_card(job_card, 10, 1)
|
||||||
@@ -2045,6 +2062,8 @@ class TestWorkOrder(FrappeTestCase):
|
|||||||
bom_no=bom_doc.name,
|
bom_no=bom_doc.name,
|
||||||
qty=1,
|
qty=1,
|
||||||
skip_transfer=1,
|
skip_transfer=1,
|
||||||
|
from_wip_warehouse=1,
|
||||||
|
source_warehouse="_Test Warehouse - _TC",
|
||||||
)
|
)
|
||||||
|
|
||||||
job_cards = frappe.get_all("Job Card", filters={"work_order": wo.name})
|
job_cards = frappe.get_all("Job Card", filters={"work_order": wo.name})
|
||||||
@@ -2451,6 +2470,37 @@ class TestWorkOrder(FrappeTestCase):
|
|||||||
|
|
||||||
frappe.db.set_single_value("Manufacturing Settings", "validate_components_quantities_per_bom", 0)
|
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):
|
def make_operation(**kwargs):
|
||||||
kwargs = frappe._dict(kwargs)
|
kwargs = frappe._dict(kwargs)
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ class WorkOrder(Document):
|
|||||||
self.validate_sales_order()
|
self.validate_sales_order()
|
||||||
self.set_default_warehouse()
|
self.set_default_warehouse()
|
||||||
self.validate_warehouse_belongs_to_company()
|
self.validate_warehouse_belongs_to_company()
|
||||||
|
self.check_wip_warehouse_skip()
|
||||||
self.calculate_operating_cost()
|
self.calculate_operating_cost()
|
||||||
self.validate_qty()
|
self.validate_qty()
|
||||||
self.validate_transfer_against()
|
self.validate_transfer_against()
|
||||||
@@ -251,6 +252,10 @@ class WorkOrder(Document):
|
|||||||
if not self.fg_warehouse:
|
if not self.fg_warehouse:
|
||||||
self.fg_warehouse = frappe.db.get_single_value("Manufacturing Settings", "default_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):
|
def validate_warehouse_belongs_to_company(self):
|
||||||
warehouses = [self.fg_warehouse, self.wip_warehouse]
|
warehouses = [self.fg_warehouse, self.wip_warehouse]
|
||||||
for d in self.get("required_items"):
|
for d in self.get("required_items"):
|
||||||
@@ -1421,7 +1426,11 @@ def make_stock_entry(work_order_id, purpose, qty=None, target_warehouse=None):
|
|||||||
stock_entry.to_warehouse = wip_warehouse
|
stock_entry.to_warehouse = wip_warehouse
|
||||||
stock_entry.project = work_order.project
|
stock_entry.project = work_order.project
|
||||||
else:
|
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.to_warehouse = work_order.fg_warehouse
|
||||||
stock_entry.project = work_order.project
|
stock_entry.project = work_order.project
|
||||||
|
|
||||||
|
|||||||
@@ -1687,13 +1687,13 @@ class TestSalesOrder(AccountsTestMixin, FrappeTestCase):
|
|||||||
wo.submit()
|
wo.submit()
|
||||||
make_stock_entry(
|
make_stock_entry(
|
||||||
item_code="_Test Item",
|
item_code="_Test Item",
|
||||||
target="Work In Progress - _TC",
|
target="_Test Warehouse - _TC",
|
||||||
qty=4,
|
qty=4,
|
||||||
basic_rate=100, # Stock RM
|
basic_rate=100, # Stock RM
|
||||||
)
|
)
|
||||||
make_stock_entry(
|
make_stock_entry(
|
||||||
item_code="_Test Item Home Desktop 100", # Stock RM
|
item_code="_Test Item Home Desktop 100", # Stock RM
|
||||||
target="Work In Progress - _TC",
|
target="_Test Warehouse - _TC",
|
||||||
qty=4,
|
qty=4,
|
||||||
basic_rate=100,
|
basic_rate=100,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user