[minor] set applicant name automatically

This commit is contained in:
Rushabh Mehta 2016-07-15 16:43:25 +05:30
parent 95383bb281
commit 55ea7b1f61
3 changed files with 16 additions and 7 deletions

View File

@ -3,16 +3,18 @@
"allow_import": 0,
"allow_rename": 0,
"autoname": "JA-.######",
"beta": 0,
"creation": "2013-01-29 19:25:37",
"custom": 0,
"description": "Applicant for a Job",
"docstatus": 0,
"doctype": "DocType",
"document_type": "Document",
"editable_grid": 0,
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"bold": 1,
"collapsible": 0,
"fieldname": "applicant_name",
"fieldtype": "Data",
@ -29,14 +31,14 @@
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"bold": 1,
"collapsible": 0,
"fieldname": "email_id",
"fieldtype": "Data",
@ -54,7 +56,7 @@
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
@ -212,13 +214,14 @@
"hide_toolbar": 0,
"icon": "icon-user",
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-03-02 02:22:31.941850",
"modified": "2016-07-15 07:10:58.195489",
"modified_by": "Administrator",
"module": "HR",
"name": "Job Applicant",
@ -245,9 +248,11 @@
"write": 1
}
],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"search_fields": "applicant_name",
"sort_order": "ASC",
"title_field": "applicant_name"
"title_field": "applicant_name",
"track_seen": 0
}

View File

@ -29,6 +29,10 @@ class JobApplicant(Document):
self.check_email_id_is_unique()
validate_email_add(self.email_id, True)
if not self.applicant_name and self.email_id:
guess = self.email_id.split('@')[0]
self.applicant_name = ' '.join([p.capitalize() for p in guess.split('.')])
def check_email_id_is_unique(self):
if self.email_id:
names = frappe.db.sql_list("""select name from `tabJob Applicant`

View File

@ -128,7 +128,7 @@ erpnext.utils.map_current_doc = function(opts) {
}
var _map = function() {
// remove first item row if empty
if($.isArray(cur_frm.doc.items)) {
if($.isArray(cur_frm.doc.items) && cur_frm.doc.items.length > 0) {
if(!cur_frm.doc.items[0].item_code) {
cur_frm.doc.items = cur_frm.doc.items.splice(1);
}