[FIX] expected browse_record can be an integer

If no filter is specified, the geoip library is installed and the user's
address can be geolocated, ``country`` is assigned an integer (the id of the
matching country) whereas the filtering code expects a browse.

fixes #1148
This commit is contained in:
Xavier Morel 2014-07-15 10:50:49 +02:00
parent 736c5dd87e
commit 03977a29e6
1 changed files with 3 additions and 2 deletions

View File

@ -38,9 +38,10 @@ class website_hr_recruitment(http.Controller):
if not country and not department and not office_id:
country_code = request.session['geoip'].get('country_code')
if country_code:
country_ids = request.registry.get('res.country').search(cr, uid, [('code', '=', country_code)], context=context)
Country = request.registry['res.country']
country_ids = Country.search(cr, uid, [('code', '=', country_code)], context=context)
if country_ids:
country = country_ids[0]
country = Country.browse(cr, uid, country_ids[0], context=context)
# 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]