mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
perf: serial no creation
This commit is contained in:
@@ -2,7 +2,7 @@ from collections import defaultdict
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, bold
|
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 import Case
|
||||||
from frappe.query_builder.functions import CombineDatetime, Sum, Timestamp
|
from frappe.query_builder.functions import CombineDatetime, Sum, Timestamp
|
||||||
from frappe.utils import add_days, cint, cstr, flt, get_link_to_form, getdate, now, nowtime, today
|
from frappe.utils import add_days, cint, cstr, flt, get_link_to_form, getdate, now, nowtime, today
|
||||||
@@ -1374,6 +1374,12 @@ class SerialBatchCreation:
|
|||||||
if self.get("voucher_type"):
|
if self.get("voucher_type"):
|
||||||
voucher_type = 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(
|
posting_date = frappe.db.get_value(
|
||||||
voucher_type,
|
voucher_type,
|
||||||
voucher_no,
|
voucher_no,
|
||||||
@@ -1381,7 +1387,9 @@ class SerialBatchCreation:
|
|||||||
)
|
)
|
||||||
|
|
||||||
for _i in range(abs(cint(self.actual_qty))):
|
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)
|
sr_nos.append(serial_no)
|
||||||
serial_nos_details.append(
|
serial_nos_details.append(
|
||||||
(
|
(
|
||||||
@@ -1426,6 +1434,8 @@ class SerialBatchCreation:
|
|||||||
|
|
||||||
frappe.db.bulk_insert("Serial No", fields=fields, values=set(serial_nos_details))
|
frappe.db.bulk_insert("Serial No", fields=fields, values=set(serial_nos_details))
|
||||||
|
|
||||||
|
obj.update_counter(current_value)
|
||||||
|
|
||||||
return sr_nos
|
return sr_nos
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user