mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 03:29:16 +00:00
fix: use serial/batch field for rejected items (#40327)
(cherry picked from commit 01856a6e9d)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -1132,6 +1132,86 @@ class TestSubcontractingReceipt(FrappeTestCase):
|
||||
scr.reload()
|
||||
self.assertTrue(scr.items[0].serial_and_batch_bundle)
|
||||
|
||||
def test_use_serial_batch_fields_for_subcontracting_receipt_with_rejected_qty(self):
|
||||
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
|
||||
|
||||
fg_item = make_item(
|
||||
"Test Subcontracted Item With Batch No for Rejected Qty",
|
||||
properties={
|
||||
"is_stock_item": 1,
|
||||
"has_batch_no": 1,
|
||||
"create_new_batch": 1,
|
||||
"batch_number_series": "BATCH-REJ-BNGS-.####",
|
||||
"is_sub_contracted_item": 1,
|
||||
},
|
||||
).name
|
||||
|
||||
make_item(
|
||||
"Test Subcontracted Item With Batch No Service Item 2",
|
||||
properties={"is_stock_item": 0},
|
||||
)
|
||||
|
||||
make_bom(
|
||||
item=fg_item,
|
||||
raw_materials=[
|
||||
make_item(
|
||||
"Test Subcontracted Item With Batch No RM Item 2",
|
||||
properties={
|
||||
"is_stock_item": 1,
|
||||
"has_batch_no": 1,
|
||||
"create_new_batch": 1,
|
||||
"batch_number_series": "BATCH-REJ-RM-BNGS-.####",
|
||||
},
|
||||
).name
|
||||
],
|
||||
)
|
||||
|
||||
service_items = [
|
||||
{
|
||||
"warehouse": "_Test Warehouse - _TC",
|
||||
"item_code": "Test Subcontracted Item With Batch No Service Item 2",
|
||||
"qty": 10,
|
||||
"rate": 100,
|
||||
"fg_item": fg_item,
|
||||
"fg_item_qty": 10,
|
||||
},
|
||||
]
|
||||
sco = get_subcontracting_order(service_items=service_items)
|
||||
rm_items = get_rm_items(sco.supplied_items)
|
||||
itemwise_details = make_stock_in_entry(rm_items=rm_items)
|
||||
make_stock_transfer_entry(
|
||||
sco_no=sco.name,
|
||||
rm_items=rm_items,
|
||||
itemwise_details=copy.deepcopy(itemwise_details),
|
||||
)
|
||||
|
||||
batch_no = "BATCH-REJ-BNGS-0001"
|
||||
if not frappe.db.exists("Batch", batch_no):
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Batch",
|
||||
"batch_id": batch_no,
|
||||
"item": fg_item,
|
||||
}
|
||||
).insert()
|
||||
|
||||
rej_warehouse = create_warehouse("_Test Subcontract Warehouse For Rejected Qty")
|
||||
|
||||
scr = make_subcontracting_receipt(sco.name)
|
||||
self.assertFalse(scr.items[0].serial_and_batch_bundle)
|
||||
scr.items[0].use_serial_batch_fields = 1
|
||||
scr.items[0].batch_no = batch_no
|
||||
scr.items[0].received_qty = 10
|
||||
scr.items[0].rejected_qty = 2
|
||||
scr.items[0].qty = 8
|
||||
scr.items[0].rejected_warehouse = rej_warehouse
|
||||
|
||||
scr.save()
|
||||
scr.submit()
|
||||
scr.reload()
|
||||
self.assertTrue(scr.items[0].serial_and_batch_bundle)
|
||||
self.assertTrue(scr.items[0].rejected_serial_and_batch_bundle)
|
||||
|
||||
|
||||
def make_return_subcontracting_receipt(**args):
|
||||
args = frappe._dict(args)
|
||||
|
||||
@@ -335,8 +335,7 @@
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Rejected Serial No",
|
||||
"no_copy": 1,
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "subcontracting_order_item",
|
||||
@@ -569,7 +568,7 @@
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2024-02-04 16:23:30.374865",
|
||||
"modified": "2024-03-07 11:43:38.954262",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Subcontracting",
|
||||
"name": "Subcontracting Receipt Item",
|
||||
|
||||
Reference in New Issue
Block a user