diff --git a/addons/website_hr_recruitment/controllers/main.py b/addons/website_hr_recruitment/controllers/main.py index e90142d04bb..a75cedaaee0 100644 --- a/addons/website_hr_recruitment/controllers/main.py +++ b/addons/website_hr_recruitment/controllers/main.py @@ -110,7 +110,7 @@ class website_hr_recruitment(http.Controller): }) return website.render("website_hr_recruitment.thankyou", values) - @http.route(['/recruitment/published'], type='http', auth="admin") + @http.route('/recruitment/published', type='json', auth="admin") def published (self, **post): hr_job = request.registry['hr.job'] id = int(post['id']) @@ -126,8 +126,8 @@ class website_hr_recruitment(http.Controller): vals['state'] = 'open' vals ['no_of_recruitment'] = 0.0 - res = hr_job.write(request.cr, request.uid, [rec.id], vals) + res = hr_job.write(request.cr, request.uid, [rec.id], vals) obj = hr_job.browse(request.cr, request.uid, id) - return obj.website_published and "1" or "0" + return { 'published': obj.website_published and "1" or "0", 'count': obj.no_of_recruitment } # vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/website_hr_recruitment/static/src/js/recruitment.js b/addons/website_hr_recruitment/static/src/js/recruitment.js index 4b6eeb730d4..9b2474cc6d7 100644 --- a/addons/website_hr_recruitment/static/src/js/recruitment.js +++ b/addons/website_hr_recruitment/static/src/js/recruitment.js @@ -5,13 +5,26 @@ $(function () { $link.find('.js_published, .js_unpublished').addClass("hidden"); var $unp = $link.find(".js_unpublished"); var $p = $link.find(".js_published"); - $.post('/recruitment/published', {'id': $link.data('id'), 'object': $link.data('object')}, function (result) { - if (+result) { + openerp.jsonRpc('/recruitment/published', 'call', {'id': $link.data('id'), 'object': $link.data('object')}).then(function (result) { + if (+result['published']) { $p.addClass("hidden"); $unp.removeClass("hidden"); + $('tr[id='+$link.data('id')+']').find('span#norecruit').addClass("hidden"); + $('tr[id='+$link.data('id')+']').find('span#counting').removeClass("hidden"); + if ($.trim($('tr[id='+$link.data('id')+']').find('span#counting').html()).length == 0) { + htmlcon = ' No.of Post: ' + result['count'] + ''; + $('tr[id='+$link.data('id')+']').find('span#counting').html(htmlcon); + } else { + $('tr[id='+$link.data('id')+']').find('span#counting').find('span#counting_num').html(result['count']); + } } else { $p.removeClass("hidden"); $unp.addClass("hidden"); + $('tr[id='+$link.data('id')+']').find('span#counting').addClass("hidden"); + $('tr[id='+$link.data('id')+']').find('span#norecruit').removeClass("hidden"); + if ($.trim($('tr[id='+$link.data('id')+']').find('span#norecruit').html()).length == 0) { + $('tr[id='+$link.data('id')+']').find('span#norecruit').html("Right now no recruitment is going on.") + } } }); }); diff --git a/addons/website_hr_recruitment/views/website_hr_recruitment.xml b/addons/website_hr_recruitment/views/website_hr_recruitment.xml index 4d810676fc1..3d41d8a237b 100644 --- a/addons/website_hr_recruitment/views/website_hr_recruitment.xml +++ b/addons/website_hr_recruitment/views/website_hr_recruitment.xml @@ -31,24 +31,27 @@ - +


- - No.of Post: - - - - - - + + + No.of Post: + + + + + + + Right now no recruitment is going on. - -
+
+ +