Merge branch 'hotfix'
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index f801959..c27ae20 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1,2 +1,2 @@
from __future__ import unicode_literals
-__version__ = '6.27.21'
+__version__ = '6.27.22'
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index 03bd587..acc4884 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -193,9 +193,6 @@
def validate_trash(self):
"""checks gl entries and if child exists"""
- if not self.parent_account:
- throw(_("Root account can not be deleted"))
-
if self.check_gle_exists():
throw(_("Account with existing transaction can not be deleted"))
if self.check_if_child_exists():
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 1eb2203..a94acff 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -7,7 +7,7 @@
app_description = """ERP made simple"""
app_icon = "icon-th"
app_color = "#e74c3c"
-app_version = "6.27.21"
+app_version = "6.27.22"
app_email = "info@erpnext.com"
app_license = "GNU General Public License (v3)"
source_link = "https://github.com/frappe/erpnext"
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 24a21d9..52dae15 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -15,13 +15,21 @@
class BOM(Document):
def autoname(self):
- last_name = frappe.db.sql("""select max(name) from `tabBOM`
- where name like "BOM/{0}/%%" and item=%s
- """.format(frappe.db.escape(self.item, percent=False)), self.item)
- if last_name:
- idx = cint(cstr(last_name[0][0]).split('/')[-1].split('-')[0]) + 1
+ names = frappe.db.sql_list("""select name from `tabBOM` where item=%s""", self.item)
+
+ if names:
+ # name can be BOM/ITEM/001, BOM/ITEM/001-1, BOM-ITEM-001, BOM-ITEM-001-1
+
+ # split by item
+ names = [name.split(self.item)[-1][1:] for name in names]
+
+ # split by (-) if cancelled
+ names = [cint(name.split('-')[-1]) for name in names]
+
+ idx = max(names) + 1
else:
idx = 1
+
self.name = 'BOM/' + self.item + ('/%.3i' % idx)
def validate(self):
diff --git a/setup.py b/setup.py
index a1088bd..d592c5f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
from pip.req import parse_requirements
-version = "6.27.21"
+version = "6.27.22"
requirements = parse_requirements("requirements.txt", session="")
setup(