mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-11 05:31:48 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user