mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-25 14:11:45 +01:00
@@ -2602,189 +2602,6 @@ class TestWorkOrder(FrappeTestCase):
|
||||
status = frappe.db.get_value("Serial No", row, "status")
|
||||
self.assertEqual(status, "Consumed")
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
def test_stock_reservation_for_serialized_raw_material(self):
|
||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import (
|
||||
make_stock_entry as make_stock_entry_test_record,
|
||||
)
|
||||
|
||||
production_item = "Test Stock Reservation FG 1"
|
||||
rm_item = "Test Stock Reservation RM 1"
|
||||
source_warehouse = "Stores - _TC"
|
||||
|
||||
make_item(production_item, {"is_stock_item": 1})
|
||||
make_item(rm_item, {"is_stock_item": 1, "has_serial_no": 1, "serial_no_series": "TST-SER-RES-.###"})
|
||||
|
||||
bom = make_bom(
|
||||
item=production_item,
|
||||
source_warehouse=source_warehouse,
|
||||
raw_materials=[rm_item],
|
||||
operating_cost_per_bom_quantity=100,
|
||||
do_not_submit=True,
|
||||
)
|
||||
|
||||
for row in bom.exploded_items:
|
||||
make_stock_entry_test_record(
|
||||
item_code=row.item_code,
|
||||
target=source_warehouse,
|
||||
qty=10,
|
||||
basic_rate=100,
|
||||
)
|
||||
|
||||
wo = make_wo_order_test_record(
|
||||
item=production_item,
|
||||
qty=10,
|
||||
reserve_stock=1,
|
||||
source_warehouse=source_warehouse,
|
||||
)
|
||||
|
||||
self.assertTrue(frappe.get_all("Stock Reservation Entry", filters={"voucher_no": wo.name}))
|
||||
|
||||
wo1 = make_wo_order_test_record(
|
||||
item=production_item,
|
||||
qty=10,
|
||||
reserve_stock=1,
|
||||
source_warehouse=source_warehouse,
|
||||
)
|
||||
|
||||
self.assertFalse(frappe.get_all("Stock Reservation Entry", filters={"voucher_no": wo1.name}))
|
||||
|
||||
transfer_entry = frappe.get_doc(make_stock_entry(wo1.name, "Material Transfer for Manufacture", 10))
|
||||
transfer_entry.save()
|
||||
|
||||
self.assertRaises(frappe.ValidationError, transfer_entry.submit)
|
||||
|
||||
def test_stock_reservation_for_batched_raw_material(self):
|
||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import (
|
||||
make_stock_entry as make_stock_entry_test_record,
|
||||
)
|
||||
|
||||
production_item = "Test Stock Reservation FG 2"
|
||||
rm_item = "Test Stock Reservation RM 2"
|
||||
source_warehouse = "Stores - _TC"
|
||||
|
||||
make_item(production_item, {"is_stock_item": 1})
|
||||
make_item(
|
||||
rm_item,
|
||||
{
|
||||
"is_stock_item": 1,
|
||||
"has_batch_no": 1,
|
||||
"batch_number_series": "TST-BATCH-RES-.###",
|
||||
"create_new_batch": 1,
|
||||
},
|
||||
)
|
||||
|
||||
bom = make_bom(
|
||||
item=production_item,
|
||||
source_warehouse=source_warehouse,
|
||||
raw_materials=[rm_item],
|
||||
operating_cost_per_bom_quantity=100,
|
||||
do_not_submit=True,
|
||||
)
|
||||
|
||||
for row in bom.exploded_items:
|
||||
make_stock_entry_test_record(
|
||||
item_code=row.item_code,
|
||||
target=source_warehouse,
|
||||
qty=10,
|
||||
basic_rate=100,
|
||||
)
|
||||
|
||||
wo = make_wo_order_test_record(
|
||||
item=production_item,
|
||||
qty=10,
|
||||
reserve_stock=1,
|
||||
source_warehouse=source_warehouse,
|
||||
)
|
||||
|
||||
self.assertTrue(frappe.get_all("Stock Reservation Entry", filters={"voucher_no": wo.name}))
|
||||
|
||||
wo1 = make_wo_order_test_record(
|
||||
item=production_item,
|
||||
qty=10,
|
||||
reserve_stock=1,
|
||||
source_warehouse=source_warehouse,
|
||||
)
|
||||
|
||||
self.assertFalse(frappe.get_all("Stock Reservation Entry", filters={"voucher_no": wo1.name}))
|
||||
|
||||
transfer_entry = frappe.get_doc(make_stock_entry(wo1.name, "Material Transfer for Manufacture", 10))
|
||||
transfer_entry.save()
|
||||
|
||||
self.assertRaises(frappe.ValidationError, transfer_entry.submit)
|
||||
|
||||
def test_auto_stock_reservation_for_batched_raw_material(self):
|
||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import (
|
||||
make_stock_entry as make_stock_entry_test_record,
|
||||
)
|
||||
|
||||
frappe.db.set_single_value("Stock Settings", "auto_reserve_serial_and_batch", 1)
|
||||
|
||||
production_item = "Test Stock Reservation FG 3"
|
||||
rm_item = "Test Stock Reservation RM 3"
|
||||
source_warehouse = "Stores - _TC"
|
||||
|
||||
make_item(production_item, {"is_stock_item": 1})
|
||||
make_item(
|
||||
rm_item,
|
||||
{
|
||||
"is_stock_item": 1,
|
||||
"has_batch_no": 1,
|
||||
"batch_number_series": "TST-BATCH-RES-.###",
|
||||
"create_new_batch": 1,
|
||||
},
|
||||
)
|
||||
|
||||
bom = make_bom(
|
||||
item=production_item,
|
||||
source_warehouse=source_warehouse,
|
||||
raw_materials=[rm_item],
|
||||
operating_cost_per_bom_quantity=100,
|
||||
do_not_submit=True,
|
||||
)
|
||||
|
||||
itemwise_batches = frappe._dict()
|
||||
for row in bom.exploded_items:
|
||||
se = make_stock_entry_test_record(
|
||||
item_code=row.item_code,
|
||||
target=source_warehouse,
|
||||
qty=10,
|
||||
basic_rate=100,
|
||||
)
|
||||
|
||||
itemwise_batches[row.item_code] = get_batch_from_bundle(se.items[0].serial_and_batch_bundle)
|
||||
|
||||
wo = make_wo_order_test_record(
|
||||
item=production_item,
|
||||
qty=10,
|
||||
reserve_stock=1,
|
||||
source_warehouse=source_warehouse,
|
||||
)
|
||||
|
||||
self.assertTrue(frappe.get_all("Stock Reservation Entry", filters={"voucher_no": wo.name}))
|
||||
|
||||
for row in frappe.get_all("Stock Reservation Entry", filters={"voucher_no": wo.name}):
|
||||
reservation_entry = frappe.get_doc("Stock Reservation Entry", row.name)
|
||||
self.assertTrue(reservation_entry.has_batch_no)
|
||||
self.assertTrue(reservation_entry.sb_entries)
|
||||
|
||||
for row in bom.exploded_items:
|
||||
make_stock_entry_test_record(
|
||||
item_code=row.item_code,
|
||||
target=source_warehouse,
|
||||
qty=10,
|
||||
basic_rate=100,
|
||||
)
|
||||
|
||||
transfer_entry = frappe.get_doc(make_stock_entry(wo.name, "Material Transfer for Manufacture", 10))
|
||||
transfer_entry.save()
|
||||
transfer_entry.submit()
|
||||
|
||||
for row in transfer_entry.items:
|
||||
batch_no = get_batch_from_bundle(row.serial_and_batch_bundle)
|
||||
self.assertEqual(batch_no, itemwise_batches[row.item_code])
|
||||
|
||||
def test_work_order_valuation_auto_pick(self):
|
||||
fg_item = "Test FG Item For Non Transfer Item Batch"
|
||||
rm_item = "Test RM Item For Non Transfer Item Batch"
|
||||
@@ -2888,7 +2705,6 @@ def make_stock_in_entries_and_get_batches(rm_item, source_warehouse, wip_warehou
|
||||
|
||||
return batches
|
||||
|
||||
>>>>>>> 5af8378471 (fix: valuation rate not updating for raw materials)
|
||||
|
||||
def make_operation(**kwargs):
|
||||
kwargs = frappe._dict(kwargs)
|
||||
|
||||
Reference in New Issue
Block a user