Added Is Active to Sales Person
diff --git a/erpnext/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js
index 98f9f6e..0a8d9a1 100755
--- a/erpnext/hr/doctype/employee/employee.js
+++ b/erpnext/hr/doctype/employee/employee.js
@@ -58,6 +58,15 @@
},
update_contact:function(frm){
frm.set_value("prefered_email",frm.fields_dict[frappe.model.scrub(frm.doc.prefered_contact_email)].value)
- }
+ },
+ status: function(frm) {
+ return frm.call({
+ method: "deactivate_sales_person",
+ args: {
+ employee: frm.doc.employee,
+ status: frm.doc.status
+ }
+ });
+ },
});
cur_frm.cscript = new erpnext.hr.EmployeeController({frm: cur_frm});
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index e2e541b..58d1262 100755
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -244,3 +244,9 @@
if holiday_list:
return frappe.get_all('Holiday List', dict(name=holiday_list, holiday_date=date)) and True or False
+@frappe.whitelist()
+def deactivate_sales_person(status = None, employee = None):
+ if status == "Left":
+ sales_person = frappe.db.get_value("Sales Person", {"Employee": employee})
+ if sales_person:
+ frappe.db.set_value("Sales Person", sales_person, "enabled", 0)
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 94212ec..213199f 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -355,4 +355,5 @@
erpnext.patches.v7_1.update_bom_base_currency
erpnext.patches.v7_0.update_status_of_po_so
erpnext.patches.v7_1.set_budget_against_as_cost_center
-erpnext.patches.v7_1.set_currency_exchange_date
\ No newline at end of file
+erpnext.patches.v7_1.set_currency_exchange_date
+erpnext.patches.v7_1.set_sales_person_status
\ No newline at end of file
diff --git a/erpnext/patches/v7_1/set_sales_person_status.py b/erpnext/patches/v7_1/set_sales_person_status.py
new file mode 100644
index 0000000..4eb4b25
--- /dev/null
+++ b/erpnext/patches/v7_1/set_sales_person_status.py
@@ -0,0 +1,7 @@
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ frappe.reload_doc('setup','doctype','sales_person')
+ frappe.db.sql("""update `tabSales Person` set enabled=1
+ where employee IN (select employee from tabEmployee where status != "Left")""")
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sales_person/sales_person.json b/erpnext/setup/doctype/sales_person/sales_person.json
index 1665ba5..595552e 100644
--- a/erpnext/setup/doctype/sales_person/sales_person.json
+++ b/erpnext/setup/doctype/sales_person/sales_person.json
@@ -29,7 +29,7 @@
"label": "Name and Employee ID",
"length": 0,
"no_copy": 0,
- "options": "fa fa-user",
+ "options": "icon-user",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -190,6 +190,35 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "default": "1",
+ "fieldname": "enabled",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Enabled",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"fieldname": "lft",
"fieldtype": "Int",
"hidden": 1,
@@ -290,7 +319,7 @@
"length": 0,
"no_copy": 0,
"oldfieldtype": "Section Break",
- "options": "fa fa-bullseye",
+ "options": "icon-bullseye",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -366,7 +395,7 @@
],
"hide_heading": 0,
"hide_toolbar": 0,
- "icon": "fa fa-user",
+ "icon": "icon-user",
"idx": 1,
"image_view": 0,
"in_create": 0,
@@ -375,7 +404,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-11-07 05:29:29.299529",
+ "modified": "2016-12-12 18:47:13.924225",
"modified_by": "Administrator",
"module": "Setup",
"name": "Sales Person",