From f0b0db444db6bf38c03d3504e85448b9d68415fa Mon Sep 17 00:00:00 2001 From: Kanchan Chauhan Date: Mon, 12 Dec 2016 11:12:07 +0530 Subject: [PATCH] Added Is Active to Sales Person --- erpnext/hr/doctype/employee/employee.js | 11 +++++- erpnext/hr/doctype/employee/employee.py | 6 +++ erpnext/patches.txt | 3 +- .../patches/v7_1/set_sales_person_status.py | 7 ++++ .../doctype/sales_person/sales_person.json | 37 +++++++++++++++++-- 5 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 erpnext/patches/v7_1/set_sales_person_status.py diff --git a/erpnext/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js index 98f9f6ea6d..0a8d9a1e49 100755 --- a/erpnext/hr/doctype/employee/employee.js +++ b/erpnext/hr/doctype/employee/employee.js @@ -58,6 +58,15 @@ frappe.ui.form.on('Employee',{ }, 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 e2e541bdb0..58d1262ae8 100755 --- a/erpnext/hr/doctype/employee/employee.py +++ b/erpnext/hr/doctype/employee/employee.py @@ -244,3 +244,9 @@ def is_holiday(employee, date=None): 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 94212ec62e..213199fea4 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -355,4 +355,5 @@ erpnext.patches.v7_0.update_autoname_field 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 0000000000..4eb4b25943 --- /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 1665ba56d0..595552ed99 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, @@ -185,6 +185,35 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "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, @@ -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",