[FIX] expected browse_record can be an integer
authorXavier Morel <xmo@openerp.com>
Tue, 15 Jul 2014 08:50:49 +0000 (10:50 +0200)
committerXavier Morel <xmo@openerp.com>
Tue, 15 Jul 2014 08:50:49 +0000 (10:50 +0200)
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

addons/website_hr_recruitment/controllers/main.py

index c99c664..a0c1773 100644 (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]