[IMP] [FIX] website_customer: fixed controllers + improved view; notably partner detail back in full form instead of calling website_partne rone, to be able to inherit from it and add some data.
bzr revid: tde@openerp.com-20131008152133-tx2ro5l0i6m1s4jx
This commit is contained in:
parent
2d128f52d8
commit
cdbd95617c
|
@ -20,49 +20,48 @@ class WebsiteCustomer(http.Controller):
|
|||
partner_obj = request.registry['res.partner']
|
||||
partner_name = post.get('search', '')
|
||||
|
||||
base_domain = [('customer', '=', True)]
|
||||
if request.context['is_public_user']:
|
||||
base_domain += [('website_published', '=', True)]
|
||||
base_domain = [('customer', '=', True), ('is_company', '=', True)]
|
||||
domain = list(base_domain)
|
||||
if partner_name:
|
||||
base_domain += [
|
||||
domain += [
|
||||
'|',
|
||||
('name', 'ilike', "%%%s%%" % post.get("search")),
|
||||
('website_description', 'ilike', "%%%s%%" % post.get("search"))
|
||||
]
|
||||
domain = base_domain
|
||||
if country_id:
|
||||
domain += [('country_id', '=', country_id)]
|
||||
|
||||
# group by country, based on all customers (base domain)
|
||||
countries = partner_obj.read_group(
|
||||
cr, openerp.SUPERUSER_ID, domain, ["id", "country_id"],
|
||||
cr, uid, base_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, uid, base_domain, count=True, context=request.context)
|
||||
countries.insert(0, {
|
||||
'country_id_count': country_count,
|
||||
'country_id': ("all", _("All Countries"))
|
||||
'country_id': (0, _("All Countries"))
|
||||
})
|
||||
|
||||
# search customers to display
|
||||
partner_ids = partner_obj.search(cr, openerp.SUPERUSER_ID, domain, context=request.context)
|
||||
partner_ids = partner_obj.search(cr, uid, domain, context=request.context)
|
||||
google_map_partner_ids = ",".join([str(p) for p in partner_ids])
|
||||
|
||||
# pager
|
||||
pager = request.website.pager(
|
||||
url="/references/", total=len(partner_ids), page=page, step=self._references_per_page,
|
||||
url="/customers/", total=len(partner_ids), page=page, step=self._references_per_page,
|
||||
scope=7, url_args=post
|
||||
)
|
||||
|
||||
# browse page of customers to display
|
||||
partner_ids = partner_obj.search(
|
||||
cr, openerp.SUPERUSER_ID, domain,
|
||||
cr, uid, domain,
|
||||
limit=self._references_per_page, offset=pager['offset'], context=context)
|
||||
partners = partner_obj.browse(request.cr, openerp.SUPERUSER_ID,
|
||||
partner_ids, request.context)
|
||||
|
||||
values = {
|
||||
'countries': countries,
|
||||
'current_country_id': country_id,
|
||||
'partner_ids': partners,
|
||||
'google_map_partner_ids': google_map_partner_ids,
|
||||
'pager': pager,
|
||||
|
|
|
@ -32,7 +32,21 @@
|
|||
Customer References<br/>
|
||||
<small>Trusted by millions worldwide</small>
|
||||
</h1>
|
||||
<div class="col-md-12" id="ref_content">
|
||||
<div class="col-md-4" id="ref_left_column">
|
||||
<h3>Search by Country</h3>
|
||||
<ul class="nav nav-pills nav-stacked mt16">
|
||||
<t t-foreach="countries" t-as="country_dict">
|
||||
<t t-if="country_dict['country_id']">
|
||||
<li t-att-class="country_dict['country_id'][0] == current_country_id and 'active' or ''">
|
||||
<a t-href="/customers/country/#{ country_dict['country_id'][0] }">
|
||||
<t t-esc="country_dict['country_id'][1]"/> <small>(<t t-esc="country_dict['country_id_count']"/>)</small>
|
||||
</a>
|
||||
</li>
|
||||
</t>
|
||||
</t>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-8" id="ref_content">
|
||||
<div class='navbar'>
|
||||
<div>
|
||||
<t t-call="website.pager">
|
||||
|
@ -65,24 +79,43 @@
|
|||
|
||||
<!-- Option: left column: World Map -->
|
||||
<template id="opt_country" inherit_id="website_customer.index" inherit_option_id="website_customer.index" name="Left World Map">
|
||||
<xpath expr="//div[@id='ref_content']" position="before">
|
||||
<div class="col-md-4">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li class="nav-header">World Map</li>
|
||||
<iframe t-attf-src="/google_map/?width=320&height=240&partner_ids=#{ google_map_partner_ids }&partner_url=/customers/"
|
||||
style="width:320px; height:260px; border:0; padding:0; margin:0;"></iframe>
|
||||
</ul>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='ref_content']" position="attributes">
|
||||
<attribute name="class">col-md-8</attribute>
|
||||
<xpath expr="//div[@id='ref_left_column']//ul[last()]" position="after">
|
||||
<h3>World Map</h3>
|
||||
<iframe t-attf-src="/google_map/?width=320&height=240&partner_ids=#{ google_map_partner_ids }&partner_url=/customers/"
|
||||
style="width:320px; height:260px; border:0; padding:0; margin:0;"></iframe>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="details" name="Customer Detail">
|
||||
<t t-call="website_customer.layout">
|
||||
<t t-set="ref_content">
|
||||
<t t-call="website_partner.partner_detail"/>
|
||||
<t t-call="website.publish_management"><t t-set="object" t-value="partner_id"/></t>
|
||||
<h1 class="col-md-12 text-center" t-field="partner_id.name"/>
|
||||
<div class="col-md-4">
|
||||
<div class="text-center">
|
||||
<img t-att-src="partner_id.img('image_medium')"/>
|
||||
</div>
|
||||
<address>
|
||||
<table style="margin: auto;" class="well">
|
||||
<colgroup>
|
||||
<col width="100"/>
|
||||
<col/>
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<t t-set="address" t-value="'<br/>'.join(partner_id.name_get()[0][1].split('\n')[1:])"/>
|
||||
<tr t-if="address or editable"><th>Address</th><td class="span2" t-raw="address"/></tr>
|
||||
<tr t-if="partner_id.website or editable"><th>Website</th><td class="span2"><span t-field="partner_id.website"/></td></tr>
|
||||
<tr t-if="partner_id.phone or editable"><th>Tel</th><td class="span2"><span t-field="partner_id.phone"/></td></tr>
|
||||
<tr t-if="partner_id.mobile or editable"><th>Tel</th><td class="span2"><span t-field="partner_id.mobile"/></td></tr>
|
||||
<tr t-if="partner_id.fax or editable"><th>Fax</th><td class="span2"><span t-field="partner_id.fax"/></td></tr>
|
||||
<tr t-if="partner_id.email or editable"><th>Email</th><td class="span2"><span t-field="partner_id.email"/></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</address>
|
||||
</div>
|
||||
<div class="col-md-8 mt32">
|
||||
<div t-field="partner_id.website_description"/>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue