From 3594dc56da679a12c908bd6e6d81c7fceff52c44 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Fri, 16 May 2014 17:42:20 -0400 Subject: [PATCH 001/161] [FIX] Add context propagation for m2m list view Fix bug https://bugs.launchpad.net/openerp-web/+bug/1279885 : Many2many fields in Tree views will not get translated. If you check the context for a name_get of a m2m field, it is passed as None. Add context propagation to m2m fields in list views. Fix translation issues when viewing a a many2many field in a Tree view. --- addons/web/static/src/js/view_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 6de354bfcb8..4cf5cc6169b 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1073,7 +1073,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web. ids = value; } new instance.web.Model(column.relation) - .call('name_get', [ids]).done(function (names) { + .call('name_get', [ids, this.dataset.context]).done(function (names) { // FIXME: nth horrible hack in this poor listview record.set(column.id + '__display', _(names).pluck(1).join(', ')); From 57e6ee4c4e6ce0744d7c220e2a8a407f464d5401 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 27 May 2014 13:50:40 +0200 Subject: [PATCH 002/161] [IMP] website_hr_recruitment: Search by country or/and department or/and by office. Default search by country with GeoIP --- .../controllers/main.py | 39 ++++++++++++++----- .../views/templates.xml | 29 +++++++++++--- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/addons/website_hr_recruitment/controllers/main.py b/addons/website_hr_recruitment/controllers/main.py index 28b960c6c91..4f8de0efac2 100644 --- a/addons/website_hr_recruitment/controllers/main.py +++ b/addons/website_hr_recruitment/controllers/main.py @@ -5,22 +5,30 @@ from openerp import SUPERUSER_ID from openerp.addons.web import http from openerp.tools.translate import _ from openerp.addons.web.http import request +import logging +_logger = logging.getLogger(__name__) + +try: + import GeoIP +except ImportError: + GeoIP = None + _logger.warn("Please install GeoIP python module to use events localisation.") class website_hr_recruitment(http.Controller): @http.route([ '/jobs', + '/jobs/country/', '/jobs/department/', - '/jobs/office/' + '/jobs/country//department/', + '/jobs/office/', + '/jobs/country//office/', + '/jobs/department//office/', + '/jobs/country//department//office/', ], type='http', auth="public", website=True) - def jobs(self, department=None, office=None): + def jobs(self, country=None, department=None, office_id=None): context=dict(request.context, show_address=True, no_tag_br=True) cr, uid = request.cr, request.uid - # office is restriced, deslugify manually - office_id = 0 - if office: - office_id = int(office.split('-')[-1]) - # Search all available jobs as uid JobsObj = request.registry['hr.job'] job_ids = JobsObj.search(cr, uid, [], order="website_published desc,no_of_recruitment desc", context=context) @@ -29,19 +37,32 @@ class website_hr_recruitment(http.Controller): jobs = JobsObj.browse(cr, 1, job_ids, context=context) # Deduce departments and offices of those jobs + countries = set(j.address_id.country_id for j in jobs if j.address_id and j.address_id.country_id) departments = set(j.department_id for j in jobs if j.department_id) offices = set(j.address_id for j in jobs if j.address_id) + # Default search by user country + if not country and not department and not office_id and GeoIP: + GI = GeoIP.open('/usr/share/GeoIP/GeoIP.dat', 0) + country_code = GI.country_code_by_addr(request.httprequest.remote_addr) + if country_code: + country_ids = request.registry.get('res.country').search(cr, uid, [('code', '=', country_code)], context=context) + if country_ids: + country = country_ids[0] + # Filter the matching one + jobs = [j for j in jobs if country==None or j.address_id==None or j.address_id.country_id and j.address_id.country_id.id == country.id] jobs = [j for j in jobs if department==None or j.department_id and j.department_id.id == department.id] - jobs = [j for j in jobs if office==None or j.address_id and j.address_id.id == office_id] + jobs = [j for j in jobs if office_id==None or j.address_id and j.address_id.id == office_id] # Render page return request.website.render("website_hr_recruitment.index", { 'jobs': jobs, + 'countries': countries, 'departments': departments, 'offices': offices, - 'department_id': department and department.id, + 'country_id': country, + 'department_id': department, 'office_id': office_id, }) diff --git a/addons/website_hr_recruitment/views/templates.xml b/addons/website_hr_recruitment/views/templates.xml index 6255b188a40..c07c1ba96e8 100644 --- a/addons/website_hr_recruitment/views/templates.xml +++ b/addons/website_hr_recruitment/views/templates.xml @@ -230,13 +230,32 @@ + +