Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/hr/doctype/job_applicant/get_job_applications.py b/hr/doctype/job_applicant/get_job_applications.py
index c5066dc..7509380 100644
--- a/hr/doctype/job_applicant/get_job_applications.py
+++ b/hr/doctype/job_applicant/get_job_applications.py
@@ -34,14 +34,23 @@
return name and name[0][0] or None
def process_message(self, mail):
+ if mail.from_email == self.settings.email_id:
+ return
+
name = self.get_existing_application(mail.from_email)
if name:
applicant = webnotes.model_wrapper("Job Applicant", name)
+ if applicant.doc.status!="Rejected":
+ applicant.doc.status = "Open"
+ applicant.doc.save()
else:
+ name = (mail.from_real_name and (mail.from_real_name + " - ") or "") \
+ + mail.from_email
applicant = webnotes.model_wrapper({
"doctype":"Job Applicant",
- "applicant_name": mail.from_real_name or mail.from_email,
- "email_id": mail.from_email
+ "applicant_name": name,
+ "email_id": mail.from_email,
+ "status": "Open"
})
applicant.insert()
diff --git a/hr/doctype/job_applicant/job_applicant.js b/hr/doctype/job_applicant/job_applicant.js
index 2b8e064..a63f833 100644
--- a/hr/doctype/job_applicant/job_applicant.js
+++ b/hr/doctype/job_applicant/job_applicant.js
@@ -2,19 +2,12 @@
cur_frm.cscript = {
refresh: function(doc) {
- cur_frm.set_intro("");
- if(doc.extract_emails) {
- cur_frm.set_intro(wn._("Active: Will extract emails from ") + doc.email_id);
- } else {
- cur_frm.set_intro(wn._("Not Active"));
- }
cur_frm.cscript.make_listing(doc);
},
make_listing: function(doc) {
- var wrapper = cur_frm.fields_dict['thread_html'].wrapper;
cur_frm.communication_view = new wn.views.CommunicationList({
- list: comm_list,
- parent: wn.model.get("Communication", {"job_applicant": doc.name}),
+ list: wn.model.get("Communication", {"job_applicant": doc.name}),
+ parent: cur_frm.fields_dict['thread_html'].wrapper,
doc: doc,
recipients: doc.email_id
})
diff --git a/hr/doctype/job_applicant/job_applicant.py b/hr/doctype/job_applicant/job_applicant.py
index 928aa9f..b4db3c0 100644
--- a/hr/doctype/job_applicant/job_applicant.py
+++ b/hr/doctype/job_applicant/job_applicant.py
@@ -2,7 +2,19 @@
from __future__ import unicode_literals
import webnotes
+from utilities.transaction_base import TransactionBase
-class DocType:
+class DocType(TransactionBase):
def __init__(self, d, dl):
- self.doc, self.doclist = d, dl
\ No newline at end of file
+ self.doc, self.doclist = d, dl
+
+ def onload(self):
+ self.add_communication_list()
+
+ def on_communication_sent(self, comm):
+ webnotes.conn.set(self.doc, 'status', 'Replied')
+
+ def on_trash(self):
+ webnotes.conn.sql("""delete from `tabCommunication`
+ where job_applicant=%s""", self.doc.name)
+
\ No newline at end of file
diff --git a/hr/doctype/job_applicant/job_applicant.txt b/hr/doctype/job_applicant/job_applicant.txt
index 390b659..0078c95 100644
--- a/hr/doctype/job_applicant/job_applicant.txt
+++ b/hr/doctype/job_applicant/job_applicant.txt
@@ -4,10 +4,11 @@
"docstatus": 0,
"creation": "2013-01-15 16:32:13",
"modified_by": "Administrator",
- "modified": "2013-01-15 17:08:46"
+ "modified": "2013-01-15 17:40:29"
},
{
"autoname": "field:applicant_name",
+ "allow_attach": 1,
"description": "Applicant for a Job",
"doctype": "DocType",
"module": "HR",
@@ -58,7 +59,7 @@
"label": "Status",
"fieldname": "status",
"fieldtype": "Select",
- "options": "Open\nReject\nHold"
+ "options": "Open\nReplied\nRejected\nHold"
},
{
"doctype": "DocField",
@@ -85,6 +86,15 @@
"fieldtype": "HTML"
},
{
+ "print_hide": 1,
+ "no_copy": 1,
+ "doctype": "DocField",
+ "label": "File List",
+ "fieldname": "file_list",
+ "fieldtype": "Text",
+ "hidden": 1
+ },
+ {
"doctype": "DocPerm"
}
]
\ No newline at end of file
diff --git a/hr/doctype/job_applicant/job_applicant_list.js b/hr/doctype/job_applicant/job_applicant_list.js
new file mode 100644
index 0000000..3d149ef
--- /dev/null
+++ b/hr/doctype/job_applicant/job_applicant_list.js
@@ -0,0 +1,41 @@
+// render
+wn.doclistviews['Job Applicant'] = wn.views.ListView.extend({
+ init: function(d) {
+ this._super(d)
+ this.fields = this.fields.concat([
+ "`tabJob Applicant`.status",
+ '`tabJob Applicant`.modified_by'
+
+ ]);
+ this.stats = this.stats.concat(['status']);
+ this.show_hide_check_column();
+ },
+
+ label_style: {
+ "status": {
+ "Open": "danger",
+ "Hold": "info",
+ "Rejected": "plain",
+ }
+ },
+
+ prepare_data: function(data) {
+ this._super(data);
+
+ data.label_style = this.label_style.status[data.status];
+ if(data.label_style=="danger")
+ data.label_style = "important"
+
+ data.status_html = repl('<span class="label \
+ label-%(label_style)s">%(status)s</span>', data);
+ },
+
+ columns: [
+ {width: '3%', content: 'check'},
+ {width: '5%', content:'avatar_modified'},
+ {width: '30%', content:'name'},
+ {width: '50%', content:'status_html'},
+ {width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
+ ]
+
+});
diff --git a/projects/doctype/timesheet/timesheet.py b/projects/doctype/timesheet/timesheet.py
index c2b296f..4f4d824 100644
--- a/projects/doctype/timesheet/timesheet.py
+++ b/projects/doctype/timesheet/timesheet.py
@@ -8,14 +8,15 @@
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
+import time, datetime
from webnotes.utils import cint, cstr, getdate, now, nowdate
from webnotes.model import db_exists
@@ -23,68 +24,71 @@
from webnotes import msgprint
sql = webnotes.conn.sql
-
-
class DocType:
- def __init__(self,doc,doclist=[]):
- self.doc = doc
- self.doclist = doclist
-
- def get_customer_details(self, project_name):
- cust = sql("select customer, customer_name from `tabProject` where name = %s", project_name)
- if cust:
- ret = {'customer': cust and cust[0][0] or '', 'customer_name': cust and cust[0][1] or ''}
- return (ret)
-
- def get_task_details(self, task_sub):
- tsk = sql("select name, project, customer, customer_name from `tabTask` where subject = %s", task_sub)
- if tsk:
- ret = {'task_id': tsk and tsk[0][0] or '', 'project_name': tsk and tsk[0][1] or '', 'customer_name': tsk and tsk[0][3] or ''}
- return ret
-
- def validate(self):
- if getdate(self.doc.timesheet_date) > getdate(nowdate()):
- msgprint("You can not prepare timesheet for future date")
- raise Exception
-
- chk = sql("select name from `tabTimesheet` where timesheet_date=%s and owner=%s and status!='Cancelled' and name!=%s", (self.doc.timesheet_date, self.doc.owner, self.doc.name))
- if chk:
- msgprint("You have already created timesheet "+ cstr(chk and chk[0][0] or '')+" for this date.")
- raise Exception
+ def __init__(self,doc,doclist=[]):
+ self.doc = doc
+ self.doclist = doclist
+
+ def get_customer_details(self, project_name):
+ cust = sql("select customer, customer_name from `tabProject` where name = %s", project_name)
+ if cust:
+ ret = {'customer': cust and cust[0][0] or '', 'customer_name': cust and cust[0][1] or ''}
+ return (ret)
+
+ def get_task_details(self, task_sub):
+ tsk = sql("select name, project, customer, customer_name from `tabTask` where subject = %s", task_sub)
+ if tsk:
+ ret = {'task_id': tsk and tsk[0][0] or '', 'project_name': tsk and tsk[0][1] or '', 'customer_name': tsk and tsk[0][3] or ''}
+ return ret
+
+ def get_time(self, timestr):
+ if len(timestr.split(":"))==2:
+ format = "%H:%M"
+ else:
+ format = "%H:%M:%S"
+
+ return time.strptime(timestr, format)
+
+ def validate(self):
+ if getdate(self.doc.timesheet_date) > getdate(nowdate()):
+ msgprint("You can not prepare timesheet for future date")
+ raise Exception
+
+ chk = sql("select name from `tabTimesheet` where timesheet_date=%s and owner=%s and status!='Cancelled' and name!=%s", (self.doc.timesheet_date, self.doc.owner, self.doc.name))
+ if chk:
+ msgprint("You have already created timesheet "+ cstr(chk and chk[0][0] or '')+" for this date.")
+ raise Exception
- import time
- for d in getlist(self.doclist, 'timesheet_details'):
- if d.act_start_time and d.act_end_time:
- d1 = time.strptime(d.act_start_time, "%H:%M")
- d2 = time.strptime(d.act_end_time, "%H:%M")
-
- if d1 > d2:
- msgprint("Start time can not be greater than end time. Check for Task Id : "+cstr(d.task_id))
- raise Exception
- elif d1 == d2:
- msgprint("Start time and end time can not be same. Check for Task Id : "+cstr(d.task_id))
- raise Exception
-
- def calculate_total_hr(self):
- import datetime
- import time
- for d in getlist(self.doclist, 'timesheet_details'):
- x1 = d.act_start_time.split(":")
- x2 = d.act_end_time.split(":")
-
- d1 = datetime.timedelta(minutes=cint(x1[1]), hours=cint(x1[0]))
- d2 = datetime.timedelta(minutes=cint(x2[1]), hours=cint(x2[0]))
- d3 = (d2 - d1).seconds
- d.act_total_hrs = time.strftime("%H:%M", time.gmtime(d3))
- sql("update `tabTimesheet Detail` set act_total_hrs = %s where parent=%s and name=%s", (d.act_total_hrs,self.doc.name,d.name))
-
- def on_update(self):
- self.calculate_total_hr()
- webnotes.conn.set(self.doc, 'status', 'Draft')
-
- def on_submit(self):
- webnotes.conn.set(self.doc, 'status', 'Submitted')
-
- def on_cancel(self):
- webnotes.conn.set(self.doc, 'status', 'Cancelled')
\ No newline at end of file
+ for d in getlist(self.doclist, 'timesheet_details'):
+ if d.act_start_time and d.act_end_time:
+ d1 = self.get_time(d.act_start_time)
+ d2 = self.get_time(d.act_end_time)
+
+ if d1 > d2:
+ msgprint("Start time can not be greater than end time. Check for Task Id : "+cstr(d.task_id))
+ raise Exception
+ elif d1 == d2:
+ msgprint("Start time and end time can not be same. Check for Task Id : "+cstr(d.task_id))
+ raise Exception
+
+ def calculate_total_hr(self):
+ for d in getlist(self.doclist, 'timesheet_details'):
+ x1 = d.act_start_time.split(":")
+ x2 = d.act_end_time.split(":")
+
+ d1 = datetime.timedelta(minutes=cint(x1[1]), hours=cint(x1[0]))
+ d2 = datetime.timedelta(minutes=cint(x2[1]), hours=cint(x2[0]))
+ d3 = (d2 - d1).seconds
+ d.act_total_hrs = time.strftime("%H:%M:%S", time.gmtime(d3))
+ sql("update `tabTimesheet Detail` set act_total_hrs = %s where parent=%s and name=%s", (d.act_total_hrs,self.doc.name,d.name))
+
+ def on_update(self):
+ self.calculate_total_hr()
+ webnotes.conn.set(self.doc, 'status', 'Draft')
+
+ def on_submit(self):
+ webnotes.conn.set(self.doc, 'status', 'Submitted')
+
+ def on_cancel(self):
+ webnotes.conn.set(self.doc, 'status', 'Cancelled')
\ No newline at end of file