From cfac9464a466a27bf3cf2c315d785093cba4ed34 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Mon, 15 Sep 2014 15:27:48 +0200 Subject: [PATCH] [FIX] website_hr_recruitment: add param to force all countries else it use GeoIP, check that country returned by GeoIP have jobs availables else fallback on all countries --- addons/crm/ir_http.py | 2 +- addons/website_hr_recruitment/controllers/main.py | 6 ++++-- addons/website_hr_recruitment/views/templates.xml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/crm/ir_http.py b/addons/crm/ir_http.py index aeebe6427b1..c3e1f445e9a 100644 --- a/addons/crm/ir_http.py +++ b/addons/crm/ir_http.py @@ -6,7 +6,7 @@ from openerp.osv import orm class ir_http(orm.AbstractModel): _inherit = 'ir.http' - def get_utm_domain_cookies(slef): + def get_utm_domain_cookies(self): return request.httprequest.host def _dispatch(self): diff --git a/addons/website_hr_recruitment/controllers/main.py b/addons/website_hr_recruitment/controllers/main.py index 2ca6e3aa3e6..6da86976511 100644 --- a/addons/website_hr_recruitment/controllers/main.py +++ b/addons/website_hr_recruitment/controllers/main.py @@ -19,7 +19,7 @@ class website_hr_recruitment(http.Controller): '/jobs/department//office/', '/jobs/country//department//office/', ], type='http', auth="public", website=True) - def jobs(self, country=None, department=None, office_id=None): + def jobs(self, country=None, department=None, office_id=None, **kwargs): env = request.env(context=dict(request.env.context, show_address=True, no_tag_br=True)) Country = env['res.country'] @@ -41,9 +41,11 @@ class website_hr_recruitment(http.Controller): if country_code: countries_ = Country.search([('code', '=', country_code)]) country = countries_[0] if countries_ else None + if not any(j for j in jobs if j.address_id and j.address_id.country_id == country): + country = False # Filter the matching one - if country: + if country and not kwargs.get('all_countries'): jobs = (j for j in jobs if j.address_id is None or j.address_id.country_id and j.address_id.country_id.id == country.id) if department: jobs = (j for j in jobs if j.department_id and j.department_id.id == department.id) diff --git a/addons/website_hr_recruitment/views/templates.xml b/addons/website_hr_recruitment/views/templates.xml index 0d1397cb6df..47280892cab 100644 --- a/addons/website_hr_recruitment/views/templates.xml +++ b/addons/website_hr_recruitment/views/templates.xml @@ -227,7 +227,7 @@