From 86cf156968de8e6514c71bfdfda99fb81c8c05b8 Mon Sep 17 00:00:00 2001 From: Samuel Danieli <23150094+scdanieli@users.noreply.github.com> Date: Tue, 31 Oct 2023 11:37:10 +0100 Subject: [PATCH] fix: set correct `purchase_sle` in `get_last_sle()` (#37708) sle_dict may look like this: { 'incoming': [ {... Stock Entry ...}, {... Purchase Receipt ...} ], 'outgoing': [ {... Stock Entry ...} ] } --- erpnext/stock/doctype/serial_no/serial_no.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index a9989956ebb4..71b2faa41dee 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -191,7 +191,7 @@ def get_last_sle(self, serial_no=None): sle_dict = self.get_stock_ledger_entries(serial_no) if sle_dict: if sle_dict.get("incoming", []): - entries["purchase_sle"] = sle_dict["incoming"][0] + entries["purchase_sle"] = sle_dict["incoming"][-1] if len(sle_dict.get("incoming", [])) - len(sle_dict.get("outgoing", [])) > 0: entries["last_sle"] = sle_dict["incoming"][0]