[FIX] website_crm_partner_assign: fixed crash when having partners to display
authorThibault Delavallée <tde@openerp.com>
Mon, 19 May 2014 14:40:50 +0000 (16:40 +0200)
committerThibault Delavallée <tde@openerp.com>
Mon, 19 May 2014 14:40:50 +0000 (16:40 +0200)
on resellers page that do not have country_id set, leading to some values
not being present in the countries variable holding data about partner
localisation.

addons/website_crm_partner_assign/controllers/main.py
addons/website_crm_partner_assign/views/website_crm_partner_assign.xml

index 3dd9679..3c9efb0 100644 (file)
@@ -65,7 +65,7 @@ class WebsiteCrmPartnerAssign(http.Controller):
             context=request.context, count=True)
         # flag active country
         for country_dict in countries:
-            country_dict['active'] = country and country_dict['country_id'][0] == country.id
+            country_dict['active'] = country and country_dict['country_id'] and country_dict['country_id'][0] == country.id
         countries.insert(0, {
             'country_id_count': countries_partners,
             'country_id': (0, _("All Countries")),
index b215a14..ed77acd 100644 (file)
@@ -53,7 +53,7 @@
                 <ul id="reseller_countries" class="nav nav-pills nav-stacked mt16">
                     <li class="nav-header"><h3>Filter by Country</h3></li>
                     <t t-foreach="countries" t-as="country">
-                        <li t-att-class="country['active'] and 'active' or ''">
+                        <li t-if="country['country_id']" t-att-class="country['active'] and 'active' or ''">
                             <a t-attf-href="/partners/#{ current_grade and 'grade/%s/' % slug(current_grade) or ''}#{country['country_id'][0] and 'country/%s/' % country['country_id'][0] or '' }#{ search_path }">
                                 <span class="badge pull-right" t-esc="country['country_id_count'] or ''"/>
                                 <t t-esc="country['country_id'][1]"/>