From 787e59c37e5475bde598ad42e5c2d0d13aa75f5c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 19 Jan 2016 15:45:15 +0530 Subject: [PATCH] [fix] BOM Autonaming --- erpnext/manufacturing/doctype/bom/bom.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 7c47cb8aff..6cfbc99ca6 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -4,17 +4,15 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, cstr, flt - from frappe import _ from frappe.model.document import Document from operator import itemgetter class BOM(Document): - def autoname(self): last_name = frappe.db.sql("""select max(name) from `tabBOM` - where name like "BOM/%s/%%" """ % frappe.db.escape(self.item)) + where name like "BOM/{0}/%%" and item=%s""".format(frappe.db.escape(self.item)), self.item) if last_name: idx = cint(cstr(last_name[0][0]).split('/')[-1].split('-')[0]) + 1 else: