[FIX]website_customer: group by country based on the result of the search, + do not display '0' right to All countries if no result + display 'No result found'

bzr revid: dle@openerp.com-20140130161132-cbn9z0i7aphzdrbn
This commit is contained in:
Denis Ledoux 2014-01-30 17:11:32 +01:00
parent 650a0b021c
commit a4a25292e7
2 changed files with 7 additions and 4 deletions

View File

@ -37,12 +37,12 @@ class WebsiteCustomer(http.Controller):
if country_id:
domain += [('country_id', '=', country_id)]
# group by country, based on all customers (base domain)
# group by country, based on customers found with the search(domain)
countries = partner_obj.read_group(
cr, openerp.SUPERUSER_ID, base_domain, ["id", "country_id"],
cr, openerp.SUPERUSER_ID, domain, ["id", "country_id"],
groupby="country_id", orderby="country_id", context=request.context)
country_count = partner_obj.search(
cr, openerp.SUPERUSER_ID, base_domain, count=True, context=request.context)
cr, openerp.SUPERUSER_ID, domain, count=True, context=request.context)
countries.insert(0, {
'country_id_count': country_count,
'country_id': (0, _("All Countries"))

View File

@ -39,6 +39,9 @@
</div>
<div class="row">
<t t-if="not partners_data">
<p>No result found.</p>
</t>
<t t-foreach="partners_data" t-as="partner_data" class="media">
<div class="col-md-2">
<a t-attf-href="/customers/#{ slug([partner_data.get('id'), partner_data.get('name')]) }/">
@ -79,7 +82,7 @@
<t t-if="country_dict['country_id']">
<li t-att-class="country_dict['country_id'][0] == current_country_id and 'active' or ''">
<a t-attf-href="/customers/#{ country_dict['country_id'][0] and 'country/%s/' % slug(country_dict['country_id']) or '' }">
<span class="badge pull-right" t-esc="country_dict['country_id_count']"/>
<span class="badge pull-right" t-esc="country_dict['country_id_count'] or ''"/>
<t t-esc="country_dict['country_id'][1]"/>
</a>
</li>