[fix] BOM Autonaming

This commit is contained in:
Nabin Hait 2016-01-19 15:45:15 +05:30
parent 77532cc8db
commit 787e59c37e

View File

@ -4,17 +4,15 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cint, cstr, flt from frappe.utils import cint, cstr, flt
from frappe import _ from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
from operator import itemgetter from operator import itemgetter
class BOM(Document): class BOM(Document):
def autoname(self): def autoname(self):
last_name = frappe.db.sql("""select max(name) from `tabBOM` 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: if last_name:
idx = cint(cstr(last_name[0][0]).split('/')[-1].split('-')[0]) + 1 idx = cint(cstr(last_name[0][0]).split('/')[-1].split('-')[0]) + 1
else: else: