perf: single query to update serial nos

This commit is contained in:
Ankush Menat 2022-01-21 13:12:31 +05:30 committed by Ankush Menat
parent 11c9a5a79f
commit ea5efd0791

View File

@ -256,11 +256,7 @@ class StockController(AccountsController):
for d in self.items:
if not d.batch_no: continue
serial_nos = [sr.name for sr in frappe.get_all("Serial No",
{'batch_no': d.batch_no, 'status': 'Inactive'})]
if serial_nos:
frappe.db.set_value("Serial No", { 'name': ['in', serial_nos] }, "batch_no", None)
frappe.db.set_value("Serial No", {"batch_no": d.batch_no, "status": "Inactive"}, "batch_no", None)
d.batch_no = None
d.db_set("batch_no", None)