2013-07-30 11:19:10 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from openerp.addons.web import http
|
2013-11-11 18:36:38 +00:00
|
|
|
from openerp.tools.translate import _
|
2013-07-30 11:19:10 +00:00
|
|
|
from openerp.addons.web.http import request
|
2013-10-01 12:39:29 +00:00
|
|
|
from openerp.addons.website.models import website
|
2013-11-04 15:52:30 +00:00
|
|
|
from openerp.addons.website.controllers.main import Website as controllers
|
|
|
|
controllers = controllers()
|
|
|
|
|
2013-07-30 11:19:10 +00:00
|
|
|
import base64
|
|
|
|
|
|
|
|
|
2013-08-01 06:45:03 +00:00
|
|
|
class website_hr_recruitment(http.Controller):
|
2013-07-30 11:19:10 +00:00
|
|
|
|
2013-11-11 18:36:38 +00:00
|
|
|
@website.route(['/jobs', '/department/<model("hr.department"):id>'], type='http', auth="public", multilang=True)
|
|
|
|
def jobs(self, department=None, page=0):
|
2013-08-13 13:38:30 +00:00
|
|
|
hr_job_obj = request.registry['hr.job']
|
2013-11-11 18:36:38 +00:00
|
|
|
domain = []
|
|
|
|
if department:
|
|
|
|
domain += [('department_id','=', department.id)]
|
|
|
|
jobpost_ids = hr_job_obj.search(request.cr, request.uid, domain, order="website_published,no_of_recruitment", context=request.context)
|
|
|
|
return request.website.render("website_hr_recruitment.index", {
|
|
|
|
'jobs': hr_job_obj.browse(request.cr, request.uid, jobpost_ids, request.context),
|
|
|
|
})
|
2013-07-30 11:19:10 +00:00
|
|
|
|
2013-10-30 23:04:06 +00:00
|
|
|
@website.route(['/job/detail/<model("hr.job"):job>'], type='http', auth="public", multilang=True)
|
2013-11-08 13:26:15 +00:00
|
|
|
def detail(self, job):
|
2013-09-05 10:25:11 +00:00
|
|
|
values = {
|
2013-10-30 23:04:06 +00:00
|
|
|
'job': job,
|
|
|
|
'vals_date': job.write_date.split(' ')[0],
|
2013-09-05 10:25:11 +00:00
|
|
|
}
|
2013-09-13 08:59:44 +00:00
|
|
|
return request.website.render("website_hr_recruitment.detail", values)
|
2013-07-30 11:19:10 +00:00
|
|
|
|
2013-10-30 17:42:25 +00:00
|
|
|
@website.route(['/job/success'], type='http', auth="admin", multilang=True)
|
2013-08-06 09:19:09 +00:00
|
|
|
def success(self, **post):
|
2013-11-11 18:36:38 +00:00
|
|
|
data = {
|
|
|
|
'name': _('Online Form'),
|
|
|
|
'phone': post.get('phone', False),
|
|
|
|
'email_from': post.get('email_from', False),
|
|
|
|
'partner_name': post.get('partner_name', False),
|
|
|
|
'description': post.get('description', False),
|
|
|
|
'department_id': post.get('department_id', False),
|
|
|
|
'job_id': post.get('job_id', False)
|
|
|
|
}
|
|
|
|
|
|
|
|
imd = request.registry['ir.model.data']
|
|
|
|
try:
|
|
|
|
model, source_id = imd.get_object_reference(request.cr, request.uid, 'hr_recruitment', 'source_website_company')
|
|
|
|
data['source_id'] = source_id
|
|
|
|
except ValueError, e:
|
|
|
|
pass
|
|
|
|
|
|
|
|
jobid = request.registry['hr.applicant'].create(request.cr, request.uid, data, context=request.context)
|
2013-07-30 11:19:10 +00:00
|
|
|
if post['ufile']:
|
|
|
|
attachment_values = {
|
|
|
|
'name': post['ufile'].filename,
|
|
|
|
'datas': base64.encodestring(post['ufile'].read()),
|
|
|
|
'datas_fname': post['ufile'].filename,
|
|
|
|
'res_model': 'hr.applicant',
|
|
|
|
'res_name': post['name'],
|
2013-11-11 18:36:38 +00:00
|
|
|
'res_id': jobid
|
2013-07-30 11:19:10 +00:00
|
|
|
}
|
2013-11-11 18:36:38 +00:00
|
|
|
request.registry['ir.attachment'].create(request.cr, request.uid, attachment_values, context=request.context)
|
|
|
|
return request.website.render("website_hr_recruitment.thankyou", {})
|
2013-10-30 17:42:25 +00:00
|
|
|
|
2013-11-11 18:36:38 +00:00
|
|
|
@website.route(['/job/apply', '/job/apply/<model("hr.job"):job>'], type='http', auth="public", multilang=True)
|
|
|
|
def applyjobpost(self, job=None):
|
2013-11-04 13:49:11 +00:00
|
|
|
return request.website.render("website_hr_recruitment.applyjobpost", { 'job': job })
|
2013-08-19 13:05:00 +00:00
|
|
|
|
2013-11-04 15:52:30 +00:00
|
|
|
@website.route('/job/publish', type='json', auth="admin", multilang=True)
|
|
|
|
def publish (self, id, object):
|
|
|
|
res = controllers.publish(id, object)
|
|
|
|
|
|
|
|
hr_job = request.registry[object]
|
2013-10-02 11:56:03 +00:00
|
|
|
id = int(id)
|
2013-09-05 10:25:11 +00:00
|
|
|
rec = hr_job.browse(request.cr, request.uid, id)
|
|
|
|
vals = {}
|
|
|
|
if rec.website_published:
|
|
|
|
vals['state'] = 'recruit'
|
2013-10-02 11:56:03 +00:00
|
|
|
if not rec.no_of_recruitment:
|
2013-09-05 10:25:11 +00:00
|
|
|
vals ['no_of_recruitment'] = 1.0
|
|
|
|
else:
|
|
|
|
vals['state'] = 'open'
|
2013-10-02 11:56:03 +00:00
|
|
|
hr_job.write(request.cr, request.uid, [rec.id], vals, context=request.context)
|
2013-09-05 10:25:11 +00:00
|
|
|
|
2013-11-04 15:52:30 +00:00
|
|
|
return res
|