Skip to content

Commit 4e828fd

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

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
@@ -1801,6 +1801,47 @@ def test_stock_reco_with_opening_stock_with_diff_inventory(self):
18011801
elif s.id_plant == plant_b.name:
18021802
self.assertEqual(s.actual_qty, 3)
18031803

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

18051846
def create_batch_item_with_batch(item_name, batch_id):
18061847
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
@@ -1071,34 +1071,6 @@ def reset_actual_qty_for_stock_reco(self, sle):
10711071
sabb_doc.voucher_no = None
10721072
sabb_doc.cancel()
10731073

1074-
if sle.serial_and_batch_bundle and frappe.get_cached_value("Item", sle.item_code, "has_serial_no"):
1075-
self.update_serial_no_status(sle)
1076-
1077-
def update_serial_no_status(self, sle):
1078-
from erpnext.stock.serial_batch_bundle import get_serial_nos
1079-
1080-
serial_nos = get_serial_nos(sle.serial_and_batch_bundle)
1081-
if not serial_nos:
1082-
return
1083-
1084-
warehouse = None
1085-
status = "Inactive"
1086-
1087-
if sle.actual_qty > 0:
1088-
warehouse = sle.warehouse
1089-
status = "Active"
1090-
1091-
sn_table = frappe.qb.DocType("Serial No")
1092-
1093-
query = (
1094-
frappe.qb.update(sn_table)
1095-
.set(sn_table.warehouse, warehouse)
1096-
.set(sn_table.status, status)
1097-
.where(sn_table.name.isin(serial_nos))
1098-
)
1099-
1100-
query.run()
1101-
11021074
def calculate_valuation_for_serial_batch_bundle(self, sle):
11031075
if not frappe.db.exists("Serial and Batch Bundle", sle.serial_and_batch_bundle):
11041076
return

0 commit comments

Comments
 (0)