mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
Merge pull request #13718 from Zlash65/enterprise
Department tree improv and moved Currency field up the list in Company
This commit is contained in:
@@ -23,6 +23,14 @@ frappe.ui.form.on('Asset', {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("department", function() {
|
||||||
|
return {
|
||||||
|
"filters": {
|
||||||
|
"company": frm.doc.company,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
|
|||||||
@@ -1,31 +1,53 @@
|
|||||||
cur_frm.add_fetch("employee", "department", "department");
|
cur_frm.add_fetch("employee", "department", "department");
|
||||||
cur_frm.add_fetch("employee", "image", "image");
|
cur_frm.add_fetch("employee", "image", "image");
|
||||||
|
|
||||||
frappe.ui.form.on("Instructor", "refresh", function(frm) {
|
frappe.ui.form.on("Instructor", {
|
||||||
if(!frm.doc.__islocal) {
|
employee: function(frm) {
|
||||||
frm.add_custom_button(__("Student Group"), function() {
|
if(!frm.doc.employee) return;
|
||||||
frappe.route_options = {
|
frappe.db.get_value('Employee', {name: frm.doc.employee}, 'company', (company) => {
|
||||||
instructor: frm.doc.name
|
frm.set_query("department", function() {
|
||||||
}
|
return {
|
||||||
frappe.set_route("List", "Student Group");
|
"filters": {
|
||||||
|
"company": company,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
frm.set_query("department", "instructor_log", function() {
|
||||||
|
return {
|
||||||
|
"filters": {
|
||||||
|
"company": company,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
frm.add_custom_button(__("Course Schedule"), function() {
|
},
|
||||||
frappe.route_options = {
|
refresh: function(frm) {
|
||||||
instructor: frm.doc.name
|
if(!frm.doc.__islocal) {
|
||||||
}
|
frm.add_custom_button(__("Student Group"), function() {
|
||||||
frappe.set_route("List", "Course Schedule");
|
frappe.route_options = {
|
||||||
});
|
instructor: frm.doc.name
|
||||||
frm.add_custom_button(__("As Examiner"), function() {
|
}
|
||||||
frappe.route_options = {
|
frappe.set_route("List", "Student Group");
|
||||||
examiner: frm.doc.name
|
});
|
||||||
}
|
frm.add_custom_button(__("Course Schedule"), function() {
|
||||||
frappe.set_route("List", "Assessment Plan");
|
frappe.route_options = {
|
||||||
}, __("Assessment Plan"));
|
instructor: frm.doc.name
|
||||||
frm.add_custom_button(__("As Supervisor"), function() {
|
}
|
||||||
frappe.route_options = {
|
frappe.set_route("List", "Course Schedule");
|
||||||
supervisor: frm.doc.name
|
});
|
||||||
}
|
frm.add_custom_button(__("As Examiner"), function() {
|
||||||
frappe.set_route("List", "Assessment Plan");
|
frappe.route_options = {
|
||||||
}, __("Assessment Plan"));
|
examiner: frm.doc.name
|
||||||
|
}
|
||||||
|
frappe.set_route("List", "Assessment Plan");
|
||||||
|
}, __("Assessment Plan"));
|
||||||
|
frm.add_custom_button(__("As Supervisor"), function() {
|
||||||
|
frappe.route_options = {
|
||||||
|
supervisor: frm.doc.name
|
||||||
|
}
|
||||||
|
frappe.set_route("List", "Assessment Plan");
|
||||||
|
}, __("Assessment Plan"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"allow_guest_to_view": 0,
|
"allow_guest_to_view": 0,
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
"autoname": "field:department_name",
|
"autoname": "",
|
||||||
"beta": 0,
|
"beta": 0,
|
||||||
"creation": "2013-02-05 11:48:26",
|
"creation": "2013-02-05 11:48:26",
|
||||||
"custom": 0,
|
"custom": 0,
|
||||||
@@ -434,7 +434,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-04-18 12:02:42.572599",
|
"modified": "2018-05-11 12:18:18.839182",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Department",
|
"name": "Department",
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ from frappe.model.document import Document
|
|||||||
class Department(NestedSet):
|
class Department(NestedSet):
|
||||||
nsm_parent_field = 'parent_department'
|
nsm_parent_field = 'parent_department'
|
||||||
|
|
||||||
|
def autoname(self):
|
||||||
|
abbr = frappe.db.get_value('Company', self.company, 'abbr')
|
||||||
|
self.name = '{0} - {1}'.format(self.department_name, abbr)
|
||||||
|
|
||||||
def update_nsm_model(self):
|
def update_nsm_model(self):
|
||||||
frappe.utils.nestedset.update_nsm(self)
|
frappe.utils.nestedset.update_nsm(self)
|
||||||
|
|
||||||
@@ -21,4 +25,23 @@ class Department(NestedSet):
|
|||||||
delete_events(self.doctype, self.name)
|
delete_events(self.doctype, self.name)
|
||||||
|
|
||||||
def on_doctype_update():
|
def on_doctype_update():
|
||||||
frappe.db.add_index("Department", ["lft", "rgt"])
|
frappe.db.add_index("Department", ["lft", "rgt"])
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_children(doctype, parent=None, company=None, is_root=False):
|
||||||
|
condition = ''
|
||||||
|
if company == parent:
|
||||||
|
condition = 'name="All Departments"'
|
||||||
|
elif company:
|
||||||
|
condition = "parent_department='{0}' and company='{1}'".format(parent, company)
|
||||||
|
else:
|
||||||
|
condition = "parent_department = '{0}'".format(parent)
|
||||||
|
|
||||||
|
return frappe.db.sql("""
|
||||||
|
select
|
||||||
|
name as value,
|
||||||
|
is_group as expandable
|
||||||
|
from `tab{doctype}`
|
||||||
|
where
|
||||||
|
{condition}
|
||||||
|
order by name""".format(doctype=doctype, condition=condition), as_dict=1)
|
||||||
|
|||||||
@@ -1,3 +1,27 @@
|
|||||||
frappe.treeview_settings["Department"] = {
|
frappe.treeview_settings["Department"] = {
|
||||||
ignore_fields:["parent_department"]
|
ignore_fields:["parent_department"],
|
||||||
|
get_tree_nodes: 'erpnext.hr.doctype.department.department.get_children',
|
||||||
|
filters: [
|
||||||
|
{
|
||||||
|
fieldname: "company",
|
||||||
|
fieldtype:"Link",
|
||||||
|
options: "Company",
|
||||||
|
label: __("Company"),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
breadcrumb: "HR",
|
||||||
|
root_label: "All Departments",
|
||||||
|
get_tree_root: true,
|
||||||
|
menu_items: [
|
||||||
|
{
|
||||||
|
label: __("New Department"),
|
||||||
|
action: function() {
|
||||||
|
frappe.new_doc("Department", true);
|
||||||
|
},
|
||||||
|
condition: 'frappe.boot.user.can_create.indexOf("Department") !== -1'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
onload: function(treeview) {
|
||||||
|
treeview.make_tree();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
@@ -37,6 +37,15 @@ erpnext.hr.EmployeeController = frappe.ui.form.Controller.extend({
|
|||||||
|
|
||||||
});
|
});
|
||||||
frappe.ui.form.on('Employee',{
|
frappe.ui.form.on('Employee',{
|
||||||
|
onload:function(frm) {
|
||||||
|
frm.set_query("department", function() {
|
||||||
|
return {
|
||||||
|
"filters": {
|
||||||
|
"company": frm.doc.company,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
prefered_contact_email:function(frm){
|
prefered_contact_email:function(frm){
|
||||||
frm.events.update_contact(frm)
|
frm.events.update_contact(frm)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,6 +2,15 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('Job Opening', {
|
frappe.ui.form.on('Job Opening', {
|
||||||
|
onload: function(frm) {
|
||||||
|
frm.set_query("department", function() {
|
||||||
|
return {
|
||||||
|
"filters": {
|
||||||
|
"company": frm.doc.company,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
designation: function(frm) {
|
designation: function(frm) {
|
||||||
if(frm.doc.designation && frm.doc.company){
|
if(frm.doc.designation && frm.doc.company){
|
||||||
frappe.call({
|
frappe.call({
|
||||||
|
|||||||
@@ -26,6 +26,19 @@ cur_frm.cscript.allocation_type = function (doc, cdt, cdn) {
|
|||||||
refresh_field('no_of_days');
|
refresh_field('no_of_days');
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.ui.form.on("Leave Control Panel", "refresh", function (frm) {
|
frappe.ui.form.on("Leave Control Panel", {
|
||||||
frm.disable_save();
|
company: function(frm) {
|
||||||
|
if(frm.doc.company) {
|
||||||
|
frm.set_query("department", function() {
|
||||||
|
return {
|
||||||
|
"filters": {
|
||||||
|
"company": frm.doc.company,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
refresh: function(frm) {
|
||||||
|
frm.disable_save();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
@@ -2,7 +2,13 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('Leave Period', {
|
frappe.ui.form.on('Leave Period', {
|
||||||
refresh: function(frm) {
|
onload: function(frm) {
|
||||||
|
frm.set_query("department", function() {
|
||||||
|
return {
|
||||||
|
"filters": {
|
||||||
|
"company": frm.doc.company,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,6 +9,14 @@ frappe.ui.form.on('Payroll Entry', {
|
|||||||
frm.doc.posting_date = frappe.datetime.nowdate();
|
frm.doc.posting_date = frappe.datetime.nowdate();
|
||||||
}
|
}
|
||||||
frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet);
|
frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet);
|
||||||
|
|
||||||
|
frm.set_query("department", function() {
|
||||||
|
return {
|
||||||
|
"filters": {
|
||||||
|
"company": frm.doc.company,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ frappe.ui.form.on('Staffing Plan', {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("department", function() {
|
||||||
|
return {
|
||||||
|
"filters": {
|
||||||
|
"company": frm.doc.company,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -527,3 +527,4 @@ erpnext.patches.v11_0.rename_field_max_days_allowed
|
|||||||
erpnext.patches.v11_0.create_salary_structure_assignments
|
erpnext.patches.v11_0.create_salary_structure_assignments
|
||||||
erpnext.patches.v11_0.rename_health_insurance
|
erpnext.patches.v11_0.rename_health_insurance
|
||||||
erpnext.patches.v11_0.rebuild_tree_for_company
|
erpnext.patches.v11_0.rebuild_tree_for_company
|
||||||
|
erpnext.patches.v11_0.create_department_records_for_each_company
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import frappe
|
||||||
|
from frappe.utils.nestedset import rebuild_tree
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doc("hr", "doctype", "department")
|
||||||
|
companies = frappe.db.get_all("Company", fields=["name", "abbr"])
|
||||||
|
departments = frappe.db.get_all("Department")
|
||||||
|
comp_dict = {}
|
||||||
|
|
||||||
|
# create a blank list for each company
|
||||||
|
for company in companies:
|
||||||
|
comp_dict[company.name] = {}
|
||||||
|
|
||||||
|
for department in departments:
|
||||||
|
# skip root node
|
||||||
|
if department.name == "All Departments":
|
||||||
|
continue
|
||||||
|
|
||||||
|
# for each company, create a copy of the doc
|
||||||
|
department_doc = frappe.get_doc("Department", department)
|
||||||
|
for company in companies:
|
||||||
|
copy_doc = frappe.copy_doc(department_doc)
|
||||||
|
copy_doc.update({"company": company.name})
|
||||||
|
copy_doc.insert()
|
||||||
|
|
||||||
|
# append list of new department for each company
|
||||||
|
comp_dict[company.name][department.name] = copy_doc.name
|
||||||
|
|
||||||
|
rebuild_tree('Department', 'parent_department')
|
||||||
|
doctypes = ["Asset", "Employee", "Leave Period", "Payroll Entry", "Staffing Plan", "Job Opening"]
|
||||||
|
|
||||||
|
for d in doctypes:
|
||||||
|
update_records(d, comp_dict)
|
||||||
|
|
||||||
|
update_instructors(comp_dict)
|
||||||
|
|
||||||
|
def update_records(doctype, comp_dict):
|
||||||
|
when_then = []
|
||||||
|
for company in comp_dict:
|
||||||
|
records = comp_dict[company]
|
||||||
|
|
||||||
|
for department in records:
|
||||||
|
when_then.append('''
|
||||||
|
WHEN company = "%s" and department = "%s"
|
||||||
|
THEN "%s"
|
||||||
|
'''%(company, department, records[department]))
|
||||||
|
|
||||||
|
frappe.db.sql("""
|
||||||
|
update
|
||||||
|
`tab%s`
|
||||||
|
set
|
||||||
|
department = CASE %s END
|
||||||
|
"""%(doctype, " ".join(when_then)))
|
||||||
|
|
||||||
|
def update_instructors(comp_dict):
|
||||||
|
when_then = []
|
||||||
|
emp_details = frappe.get_all("Employee", fields=["name", "company"])
|
||||||
|
|
||||||
|
for employee in emp_details:
|
||||||
|
records = comp_dict[employee.company]
|
||||||
|
|
||||||
|
for department in records:
|
||||||
|
when_then.append('''
|
||||||
|
WHEN employee = "%s" and department = "%s"
|
||||||
|
THEN "%s"
|
||||||
|
'''%(employee.name, department, records[department]))
|
||||||
|
|
||||||
|
frappe.db.sql("""
|
||||||
|
update
|
||||||
|
`tabInstructor`
|
||||||
|
set
|
||||||
|
department = CASE %s END
|
||||||
|
"""%(" ".join(when_then)))
|
||||||
@@ -456,7 +456,38 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "default_letter_head",
|
"fieldname": "default_currency",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 1,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Default Currency",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "Currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "default_letter_head",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@@ -465,10 +496,10 @@
|
|||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Default Letter Head",
|
"label": "Default Letter Head",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "Letter Head",
|
"options": "Letter Head",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@@ -488,7 +519,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "default_holiday_list",
|
"fieldname": "default_holiday_list",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@@ -497,12 +528,12 @@
|
|||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Default Holiday List",
|
"label": "Default Holiday List",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "Holiday List",
|
"options": "Holiday List",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
@@ -520,57 +551,26 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "default_terms",
|
"fieldname": "default_terms",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Default Terms",
|
"label": "Default Terms",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "Terms and Conditions",
|
"options": "Terms and Conditions",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"remember_last_selected_value": 0,
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "default_currency",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 1,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Default Currency",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user