[FIX] website_hr_recruitment: add param to force all countries else it use GeoIP...
authorJeremy Kersten <jke@odoo.com>
Mon, 15 Sep 2014 13:27:48 +0000 (15:27 +0200)
committerJeremy Kersten <jke@odoo.com>
Mon, 15 Sep 2014 13:27:48 +0000 (15:27 +0200)
addons/crm/ir_http.py
addons/website_hr_recruitment/controllers/main.py
addons/website_hr_recruitment/views/templates.xml

index aeebe64..c3e1f44 100644 (file)
@@ -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):
index 2ca6e3a..6da8697 100644 (file)
@@ -19,7 +19,7 @@ class website_hr_recruitment(http.Controller):
         '/jobs/department/<model("hr.department"):department>/office/<int:office_id>',
         '/jobs/country/<model("res.country"):country>/department/<model("hr.department"):department>/office/<int:office_id>',
     ], 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)
index 0d1397c..4728089 100644 (file)
 <template id="job_countries" inherit_id="website_hr_recruitment.index" active="False" customize_show="True" name="Filter by Countries">
     <xpath expr="//div[@id='jobs_grid_left']" position="inside">
         <ul class="nav nav-pills nav-stacked mb32">
-            <li t-att-class=" '' if country_id else 'active' "><a t-attf-href="/jobs#{ '/department/%s' % slug(department_id) if department_id else '' }#{ '/office/%s' % office_id if office_id else '' }">All Countries</a></li>
+            <li t-att-class=" '' if country_id else 'active' "><a t-attf-href="/jobs#{ '/country/all/department/%s' % slug(department_id) if department_id else '' }#{ '/office/%s' % office_id if office_id else '' }?all_country=1">All Countries</a></li>
             <t t-foreach="countries" t-as="country">
                 <li t-att-class="'active' if country_id and country_id.id == country.id else ''">
                     <a t-attf-href="/jobs/country/#{ slug(country) }#{ '/department/%s' % slug(department_id) if department_id else '' }#{ '/office/%s' % office_id if office_id else '' }" ><span t-field="country.name"/></a>