Skip to content

Commit cb24d94

Browse files
fix: remove unneccessary function for serial no status updation (backport #54191) (#54196)
Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com> fix: remove unneccessary function for serial no status updation (#54191)
1 parent bc6780d commit cb24d94

2 files changed

Lines changed: 41 additions & 28 deletions

File tree

erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,47 @@ def test_stock_reco_with_opening_stock_with_diff_inventory(self):
17931793
elif s.id_plant == plant_b.name:
17941794
self.assertEqual(s.actual_qty, 3)
17951795

1796+
def test_serial_no_status_with_backdated_stock_reco(self):
1797+
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
1798+
1799+
item_code = self.make_item(
1800+
"Test Item",
1801+
{
1802+
"is_stock_item": 1,
1803+
"has_serial_no": 1,
1804+
"serial_no_series": "SERIAL.###",
1805+
},
1806+
).name
1807+
1808+
warehouse = "_Test Warehouse - _TC"
1809+
1810+
reco = create_stock_reconciliation(
1811+
item_code=item_code,
1812+
posting_date=add_days(nowdate(), -2),
1813+
warehouse=warehouse,
1814+
qty=1,
1815+
rate=80,
1816+
purpose="Opening Stock",
1817+
)
1818+
1819+
serial_no = get_serial_nos_from_bundle(reco.items[0].serial_and_batch_bundle)[0]
1820+
1821+
create_delivery_note(
1822+
item_code=item_code, warehouse=warehouse, qty=1, rate=100, posting_date=nowdate()
1823+
)
1824+
1825+
self.assertEqual(frappe.get_value("Serial No", serial_no, "status"), "Delivered")
1826+
1827+
reco = create_stock_reconciliation(
1828+
item_code=item_code,
1829+
posting_date=add_days(nowdate(), -1),
1830+
warehouse=warehouse,
1831+
qty=1,
1832+
rate=90,
1833+
)
1834+
1835+
self.assertEqual(frappe.get_value("Serial No", serial_no, "status"), "Delivered")
1836+
17961837

17971838
def create_batch_item_with_batch(item_name, batch_id):
17981839
batch_item_doc = create_item(item_name, is_stock_item=1)

erpnext/stock/stock_ledger.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,34 +1063,6 @@ def reset_actual_qty_for_stock_reco(self, sle):
10631063
sabb_doc.voucher_no = None
10641064
sabb_doc.cancel()
10651065

1066-
if sle.serial_and_batch_bundle and frappe.get_cached_value("Item", sle.item_code, "has_serial_no"):
1067-
self.update_serial_no_status(sle)
1068-
1069-
def update_serial_no_status(self, sle):
1070-
from erpnext.stock.serial_batch_bundle import get_serial_nos
1071-
1072-
serial_nos = get_serial_nos(sle.serial_and_batch_bundle)
1073-
if not serial_nos:
1074-
return
1075-
1076-
warehouse = None
1077-
status = "Inactive"
1078-
1079-
if sle.actual_qty > 0:
1080-
warehouse = sle.warehouse
1081-
status = "Active"
1082-
1083-
sn_table = frappe.qb.DocType("Serial No")
1084-
1085-
query = (
1086-
frappe.qb.update(sn_table)
1087-
.set(sn_table.warehouse, warehouse)
1088-
.set(sn_table.status, status)
1089-
.where(sn_table.name.isin(serial_nos))
1090-
)
1091-
1092-
query.run()
1093-
10941066
def calculate_valuation_for_serial_batch_bundle(self, sle):
10951067
if not frappe.db.exists("Serial and Batch Bundle", sle.serial_and_batch_bundle):
10961068
return

0 commit comments

Comments
 (0)