patch fixes

This commit is contained in:
Nabin Hait 2018-05-29 16:17:06 +05:30
parent 13d4391e70
commit 348a6a8b17
3 changed files with 6 additions and 11 deletions

View File

@ -3,7 +3,6 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils.nestedset import NestedSet, get_root_of
from erpnext.utilities.transaction_base import delete_events
from frappe.model.document import Document
@ -12,7 +11,8 @@ class Department(NestedSet):
nsm_parent_field = 'parent_department'
def autoname(self):
if self.department_name != get_root_of("Department"):
root = get_root_of("Department")
if root and self.department_name != root:
abbr = frappe.db.get_value('Company', self.company, 'abbr')
self.name = '{0} - {1}'.format(self.department_name, abbr)
else:

View File

@ -25,13 +25,11 @@ def build_tree():
where is_group = 0""".format(_('All Supplier Groups')))
if not frappe.db.exists("Supplier Group", _('All Supplier Groups')):
supplier_group = frappe.get_doc({
frappe.get_doc({
'doctype': 'Supplier Group',
'supplier_group_name': _('All Supplier Groups'),
'is_group': 1,
'parent_supplier_group': ''
})
supplier_group.flags.ignore_validate=True
supplier_group.insert(ignore_permissions=True)
}).insert(ignore_permissions=True)
rebuild_tree("Supplier Group", "parent_supplier_group")

View File

@ -5,15 +5,12 @@ from frappe.utils.nestedset import rebuild_tree
def execute():
""" assign lft and rgt appropriately """
frappe.reload_doc("hr", "doctype", "department")
if not frappe.db.exists("Department", _('All Departments')):
dept = frappe.get_doc({
frappe.get_doc({
'doctype': 'Department',
'department_name': _('All Departments'),
'is_group': 1
})
dept.flags.ignore_validate=True
dept.insert(ignore_permissions=True)
}).insert(ignore_permissions=True)
frappe.db.sql("""update `tabDepartment` set parent_department = '{0}'
where is_group = 0""".format(_('All Departments')))