fix: Retain space inside Serial no string while cleaning serial nos
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 4697205..dfb53c7 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -79,8 +79,15 @@
def clean_serial_nos(self):
for row in self.get("items"):
if hasattr(row, "serial_no") and row.serial_no:
- # replace commas by linefeed and remove all spaces in string
- row.serial_no = row.serial_no.replace(",", "\n").replace(" ", "")
+ # replace commas by linefeed
+ row.serial_no = row.serial_no.replace(",", "\n")
+
+ # strip preceeding and succeeding spaces for each SN
+ # (SN could have valid spaces in between e.g. SN - 123 - 2021)
+ serial_no_list = row.serial_no.split("\n")
+ serial_no_list = [sn.lstrip().rstrip() for sn in serial_no_list]
+
+ row.serial_no = "\n".join(serial_no_list)
def get_gl_entries(self, warehouse_account=None, default_expense_account=None,
default_cost_center=None):