fix(stock): make get_incoming_value_for_serial_nos a staticmethod

It never references `self`. The deterministic-serial-value test added in #56249
called it as `get_incoming_value_for_serial_nos(None, sle, serial_nos)` — passing
None for self, which is fragile: a future `self.*` access would fail with an opaque
AttributeError. Declaring it @staticmethod makes the call honest
(`get_incoming_value_for_serial_nos(sle, serial_nos)`) and is backward compatible —
the method has no in-repo callers besides that test, and any `self.`-style call still
binds correctly to a staticmethod.

Addresses Greptile review feedback on #56249.
This commit is contained in:
Mihir Kandoi
2026-06-21 14:56:29 +05:30
parent ed1261ef8d
commit 81a0709dbd
2 changed files with 3 additions and 2 deletions

View File

@@ -77,7 +77,7 @@ class TestStockLedgerEntry(ERPNextTestSuite, StockTestMixin):
mk_sle("MAT-SLE-TIE-B", 200) # later/larger name -> deterministic winner
value = update_entries_after.get_incoming_value_for_serial_nos(
None, frappe._dict(company=company_a), [serial]
frappe._dict(company=company_a), [serial]
)
# the latest (creation/name desc) same-date SLE wins -> 200 on both engines
self.assertEqual(value, 200.0)

View File

@@ -1473,7 +1473,8 @@ class update_entries_after:
for item in sr.items:
item.db_update()
def get_incoming_value_for_serial_nos(self, sle, serial_nos):
@staticmethod
def get_incoming_value_for_serial_nos(sle, serial_nos):
# get rate from serial nos within same company
all_serial_nos = frappe.get_all(
"Serial No", fields=["purchase_rate", "name", "company"], filters={"name": ("in", serial_nos)}