perf: serial no creation

(cherry picked from commit 19a9497273)

# Conflicts:
#	erpnext/stock/serial_batch_bundle.py
This commit is contained in:
Rohit Waghchaure
2025-11-10 16:35:36 +05:30
committed by Mergify
parent b5485dc909
commit 6ba24912c3

View File

@@ -2,7 +2,7 @@ from collections import defaultdict
import frappe
from frappe import _, bold
from frappe.model.naming import make_autoname
from frappe.model.naming import NamingSeries, make_autoname, parse_naming_series
from frappe.query_builder import Case
from frappe.query_builder.functions import CombineDatetime, Sum, Timestamp
from frappe.utils import add_days, cint, cstr, flt, get_link_to_form, now, nowtime, today
@@ -1334,8 +1334,29 @@ class SerialBatchCreation:
if self.get("voucher_no"):
voucher_no = self.get("voucher_no")
<<<<<<< HEAD
=======
voucher_type = ""
if self.get("voucher_type"):
voucher_type = self.get("voucher_type")
obj = NamingSeries(self.serial_no_series)
current_value = obj.get_current_value()
def get_series(partial_series, digits):
return f"{current_value:0{digits}d}"
posting_date = frappe.db.get_value(
voucher_type,
voucher_no,
"posting_date",
)
>>>>>>> 19a9497273 (perf: serial no creation)
for _i in range(abs(cint(self.actual_qty))):
serial_no = make_autoname(self.serial_no_series, "Serial No")
current_value += 1
serial_no = parse_naming_series(self.serial_no_series, number_generator=get_series)
sr_nos.append(serial_no)
serial_nos_details.append(
(
@@ -1376,6 +1397,8 @@ class SerialBatchCreation:
frappe.db.bulk_insert("Serial No", fields=fields, values=set(serial_nos_details))
obj.update_counter(current_value)
return sr_nos