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)
This commit is contained in:
mergify[bot]
2026-04-10 10:58:57 +00:00
committed by GitHub
parent 3cf90e804d
commit 4e828fd897
2 changed files with 41 additions and 28 deletions

View File

@@ -1801,6 +1801,47 @@ class TestStockReconciliation(ERPNextTestSuite, StockTestMixin):
elif s.id_plant == plant_b.name:
self.assertEqual(s.actual_qty, 3)
def test_serial_no_status_with_backdated_stock_reco(self):
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
item_code = self.make_item(
"Test Item",
{
"is_stock_item": 1,
"has_serial_no": 1,
"serial_no_series": "SERIAL.###",
},
).name
warehouse = "_Test Warehouse - _TC"
reco = create_stock_reconciliation(
item_code=item_code,
posting_date=add_days(nowdate(), -2),
warehouse=warehouse,
qty=1,
rate=80,
purpose="Opening Stock",
)
serial_no = get_serial_nos_from_bundle(reco.items[0].serial_and_batch_bundle)[0]
create_delivery_note(
item_code=item_code, warehouse=warehouse, qty=1, rate=100, posting_date=nowdate()
)
self.assertEqual(frappe.get_value("Serial No", serial_no, "status"), "Delivered")
reco = create_stock_reconciliation(
item_code=item_code,
posting_date=add_days(nowdate(), -1),
warehouse=warehouse,
qty=1,
rate=90,
)
self.assertEqual(frappe.get_value("Serial No", serial_no, "status"), "Delivered")
def create_batch_item_with_batch(item_name, batch_id):
batch_item_doc = create_item(item_name, is_stock_item=1)

View File

@@ -1071,34 +1071,6 @@ class update_entries_after:
sabb_doc.voucher_no = None
sabb_doc.cancel()
if sle.serial_and_batch_bundle and frappe.get_cached_value("Item", sle.item_code, "has_serial_no"):
self.update_serial_no_status(sle)
def update_serial_no_status(self, sle):
from erpnext.stock.serial_batch_bundle import get_serial_nos
serial_nos = get_serial_nos(sle.serial_and_batch_bundle)
if not serial_nos:
return
warehouse = None
status = "Inactive"
if sle.actual_qty > 0:
warehouse = sle.warehouse
status = "Active"
sn_table = frappe.qb.DocType("Serial No")
query = (
frappe.qb.update(sn_table)
.set(sn_table.warehouse, warehouse)
.set(sn_table.status, status)
.where(sn_table.name.isin(serial_nos))
)
query.run()
def calculate_valuation_for_serial_batch_bundle(self, sle):
if not frappe.db.exists("Serial and Batch Bundle", sle.serial_and_batch_bundle):
return