[REF] website_contract: renamed website_customer, now only displaying customers.
This module is not based on account.analytic.account anymore. Instead published customers are displayed. A further step is the 'implemented by' feature that iwll be provided by crm_partner_assign module (probably). Display will also have to be cleaned. bzr revid: tde@openerp.com-20131008083956-tb1fceo9y78mm728
This commit is contained in:
parent
c82f6f7ef6
commit
b87ddc1bf4
|
@ -1 +0,0 @@
|
|||
import controllers
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
'name': 'Public References',
|
||||
'category': 'Website',
|
||||
'summary': 'Publish Customer References',
|
||||
'version': '1.0',
|
||||
'description': """
|
||||
OpenERP Blog
|
||||
============
|
||||
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['website_partner', 'sale', 'website_google_map'],
|
||||
'data': [
|
||||
'views/website_contract.xml',
|
||||
],
|
||||
'qweb': ['static/src/xml/*.xml'],
|
||||
'installable': True,
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import openerp
|
||||
from openerp.addons.web import http
|
||||
from openerp.tools.translate import _
|
||||
from openerp.addons.web.http import request
|
||||
from openerp.addons.website.models import website
|
||||
import urllib
|
||||
|
||||
|
||||
class website_contract(http.Controller):
|
||||
|
||||
@website.route(['/references/', '/references/page/<int:page>/'], type='http', auth="public")
|
||||
def references(self, page=0, **post):
|
||||
partner_obj = request.registry['res.partner']
|
||||
account_obj = request.registry['account.analytic.account']
|
||||
|
||||
# check contracts
|
||||
contract_ids = account_obj.search(request.cr, openerp.SUPERUSER_ID, [(1, "=", 1)])
|
||||
contracts = account_obj.browse(request.cr, openerp.SUPERUSER_ID,
|
||||
contract_ids, request.context)
|
||||
contract_project_ids = [contract.partner_id.id for contract in contracts
|
||||
if contract.partner_id]
|
||||
domain = ['|', ('id', "in", contract_project_ids), ('id', "child_of", contract_project_ids)]
|
||||
|
||||
if post.get('search'):
|
||||
domain += [
|
||||
'|',
|
||||
('name', 'ilike', "%%%s%%" % post.get("search")),
|
||||
('website_description', 'ilike', "%%%s%%" % post.get("search"))
|
||||
]
|
||||
if request.context['is_public_user']:
|
||||
domain = ['&'] + domain + [('website_published', '=', True)]
|
||||
|
||||
# public partner profile
|
||||
partner_ids = partner_obj.search(
|
||||
request.cr, openerp.SUPERUSER_ID,
|
||||
domain + [('website_published', '=', True)], context=request.context)
|
||||
google_map_partner_ids = ",".join([str(p) for p in partner_ids])
|
||||
|
||||
# group by country
|
||||
countries = partner_obj.read_group(
|
||||
request.cr, request.uid, domain, ["id", "country_id"],
|
||||
groupby="country_id", orderby="country_id", context=request.context)
|
||||
country_count = partner_obj.search(
|
||||
request.cr, request.uid, domain, count=True, context=request.context)
|
||||
countries.insert(0, {
|
||||
'country_id_count': country_count,
|
||||
'country_id': ("all", _("All Countries"))
|
||||
})
|
||||
|
||||
if post.get("country", "all") != 'all':
|
||||
partner_ids = partner_obj.search(
|
||||
request.cr, request.uid,
|
||||
[
|
||||
('id', 'in', partner_ids),
|
||||
('country_id', '=', int(post.get('country')))
|
||||
], context=request.context)
|
||||
|
||||
step = 20
|
||||
pager = request.website.pager(url="/references/", total=len(partner_ids), page=page, step=step, scope=7, url_args=post)
|
||||
partner_ids = partner_obj.search(
|
||||
request.cr, openerp.SUPERUSER_ID, [('id', 'in', partner_ids)],
|
||||
limit=step, offset=pager['offset'], context=request.context)
|
||||
partners = partner_obj.browse(request.cr, openerp.SUPERUSER_ID,
|
||||
partner_ids, request.context)
|
||||
values = {
|
||||
'countries': countries,
|
||||
'partner_ids': partners,
|
||||
'google_map_partner_ids': google_map_partner_ids,
|
||||
'pager': pager,
|
||||
'searches': post,
|
||||
'search_path': "?%s" % urllib.urlencode(post),
|
||||
}
|
||||
return request.website.render("website_contract.index", values)
|
||||
|
||||
@website.route(['/references/<int:partner_id>/'], type='http', auth="public")
|
||||
def references_ref(self, partner_id=None, **post):
|
||||
""" Route for displaying a single partner.
|
||||
|
||||
:param integer partner_id: partner to display. If not set or not valid
|
||||
call basic references method.
|
||||
"""
|
||||
partner_obj = request.registry['res.partner']
|
||||
if request.context['is_public_user']:
|
||||
partner_ids = partner_obj.search(
|
||||
request.cr, openerp.SUPERUSER_ID, [
|
||||
('website_published', '=', True),
|
||||
('id', '=', partner_id)
|
||||
], context=request.context)
|
||||
partner_id = partner_ids and partner_ids[0] or None
|
||||
|
||||
if not partner_id:
|
||||
return self.references(post=post)
|
||||
|
||||
values = {
|
||||
'partner_id': partner_obj.browse(
|
||||
request.cr, openerp.SUPERUSER_ID, partner_id,
|
||||
dict(request.context, show_address=True)),
|
||||
}
|
||||
|
||||
return request.website.render("website_contract.details", values)
|
|
@ -1,129 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<!-- Layout add nav and footer -->
|
||||
|
||||
<template id="footer_custom" inherit_id="website.layout" name="Custom Footer">
|
||||
<xpath expr="//footer//div[@name='info']/ul" position="inside">
|
||||
<li><a href="/references/">References</a></li>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Page -->
|
||||
|
||||
<template id="layout" name="References Layout">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="title">References</t>
|
||||
<div id="wrap">
|
||||
<div class="oe_structure"/>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<t t-raw="ref_content" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="oe_structure"/>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="index" name="References">
|
||||
<t t-call="website_contract.layout">
|
||||
<t t-set="ref_content">
|
||||
<h1 class="col-md-12 text-center">
|
||||
Customer References<br/>
|
||||
<small>Trusted by millions worldwide</small>
|
||||
</h1>
|
||||
<div class="col-md-12" id="ref_content">
|
||||
<div class='navbar'>
|
||||
<div>
|
||||
<t t-call="website.pager">
|
||||
<t t-set="classname" t-value="'pull-left'"/>
|
||||
</t>
|
||||
<form action="/references/" method="get" class="navbar-search pull-right pagination form-inline">
|
||||
<div class="form-group">
|
||||
<input type="text" name="search" class="search-query form-control" placeholder="Search" t-att-value="searches.get('search') or '' or ''" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<select class="search-query form-control" name="country" t-if="len(countries) > 1" onchange="submit()">
|
||||
<t t-foreach="countries">
|
||||
<t t-if="country_id">
|
||||
<option t-att-selected="searches.get('country') == str(country_id and country_id[0]) and 'selected'" t-att-value="country_id[0]">
|
||||
<t t-esc="country_id[1]"/> (<t t-esc="country_id_count"/>)
|
||||
</option>
|
||||
</t>
|
||||
</t>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div t-foreach="partner_ids" t-as="partner" class="media thumbnail" data-publish="">
|
||||
<t t-call="website.publish_management"><t t-set="object" t-value="partner"/></t>
|
||||
<a class="pull-left" t-attf-href="/references/#{ partner.id }/">
|
||||
<img class="media-object" t-att-src="partner.img('image_small')"/>
|
||||
</a>
|
||||
<div class="media-body" style="min-height: 64px;">
|
||||
<a class="media-heading" t-attf-href="/references/#{ partner.id }/"><span t-field="partner.parent_id"/> <span t-field="partner.name"/></a>
|
||||
<div t-field="partner.website_short_description"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="ref_country" inherit_id="website_contract.index" inherit_option_id="website_contract.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=/references/"
|
||||
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>
|
||||
</template>
|
||||
|
||||
<template id="details" name="Reference Detail">
|
||||
<t t-call="website_contract.layout">
|
||||
<t t-set="ref_content">
|
||||
<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>
|
||||
<div class="mt32" t-field="partner_id.website_short_description"/>
|
||||
<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="col-md-2" t-raw="address"/></tr>
|
||||
<tr t-if="partner_id.website or editable"><th>Website</th><td class="col-md-2"><span t-field="partner_id.website"/></td></tr>
|
||||
<tr t-if="partner_id.phone or editable"><th>Tel</th><td class="col-md-2"><span t-field="partner_id.phone"/></td></tr>
|
||||
<tr t-if="partner_id.mobile or editable"><th>Tel</th><td class="col-md-2"><span t-field="partner_id.mobile"/></td></tr>
|
||||
<tr t-if="partner_id.fax or editable"><th>Fax</th><td class="col-md-2"><span t-field="partner_id.fax"/></td></tr>
|
||||
<tr t-if="partner_id.email or editable"><th>Email</th><td class="col-md-2"><span t-field="partner_id.email"/></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</address>
|
||||
</div>
|
||||
<div class="col-md-8 mt32" t-field="partner_id.website_description"/>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2013-Today OpenERP S.A. (<http://www.openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import controllers
|
|
@ -0,0 +1,41 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2013-Today OpenERP S.A. (<http://www.openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
'name': 'Public Customer References',
|
||||
'category': 'Website',
|
||||
'summary': 'Publish Customer References on your Website',
|
||||
'version': '1.0',
|
||||
'description': """
|
||||
OpenERP Customer References
|
||||
===========================
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': [
|
||||
'website_partner',
|
||||
'website_google_map'
|
||||
],
|
||||
'data': [
|
||||
'views/website_customer.xml',
|
||||
],
|
||||
'qweb': [],
|
||||
'installable': True,
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import openerp
|
||||
from openerp.addons.web import http
|
||||
from openerp.tools.translate import _
|
||||
from openerp.addons.web.http import request
|
||||
from openerp.addons.website.models import website
|
||||
import urllib
|
||||
|
||||
|
||||
class WebsiteCustomer(http.Controller):
|
||||
_references_per_page = 20
|
||||
|
||||
@website.route([
|
||||
'/customers/', '/customers/page/<int:page>/',
|
||||
'/customers/country/<int:country_id>', '/customers/country/<int:country_id>/page/<int:page>/'
|
||||
], type='http', auth="public")
|
||||
def customers(self, country_id=None, page=0, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
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)]
|
||||
if partner_name:
|
||||
base_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"],
|
||||
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)
|
||||
countries.insert(0, {
|
||||
'country_id_count': country_count,
|
||||
'country_id': ("all", _("All Countries"))
|
||||
})
|
||||
|
||||
# search customers to display
|
||||
partner_ids = partner_obj.search(cr, openerp.SUPERUSER_ID, 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,
|
||||
scope=7, url_args=post
|
||||
)
|
||||
|
||||
# browse page of customers to display
|
||||
partner_ids = partner_obj.search(
|
||||
cr, openerp.SUPERUSER_ID, 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,
|
||||
'partner_ids': partners,
|
||||
'google_map_partner_ids': google_map_partner_ids,
|
||||
'pager': pager,
|
||||
'post': post,
|
||||
'search_path': "?%s" % urllib.urlencode(post),
|
||||
}
|
||||
return request.website.render("website_customer.index", values)
|
||||
|
||||
@website.route(['/customers/<int:partner_id>/'], type='http', auth="public")
|
||||
def customer(self, partner_id=None, **post):
|
||||
""" Route for displaying a single partner / customer.
|
||||
|
||||
:param integer partner_id: partner to display. If not set or not valid
|
||||
call basic references method.
|
||||
"""
|
||||
partner_obj = request.registry['res.partner']
|
||||
if request.context['is_public_user']:
|
||||
partner_ids = partner_obj.search(
|
||||
request.cr, openerp.SUPERUSER_ID, [
|
||||
('website_published', '=', True),
|
||||
('id', '=', partner_id)
|
||||
], context=request.context)
|
||||
partner_id = partner_ids and partner_ids[0] or None
|
||||
|
||||
if not partner_id:
|
||||
return self.references(post=post)
|
||||
|
||||
values = {
|
||||
'partner_id': partner_obj.browse(
|
||||
request.cr, openerp.SUPERUSER_ID, partner_id,
|
||||
dict(request.context, show_address=True)),
|
||||
}
|
||||
|
||||
return request.website.render("website_customer.details", values)
|
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Layout add nav and footer -->
|
||||
<template id="footer_custom" inherit_id="website.layout" name="Custom Footer">
|
||||
<xpath expr="//footer//div[@name='info']/ul" position="inside">
|
||||
<li><a href="/customers/">Customer References</a></li>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Page -->
|
||||
<template id="layout" name="Customer References Layout">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="title">Customer References</t>
|
||||
<div id="wrap">
|
||||
<div class="oe_structure"/>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<t t-raw="ref_content"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oe_structure"/>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="index" name="Customer References">
|
||||
<t t-call="website_customer.layout">
|
||||
<t t-set="ref_content">
|
||||
<h1 class="col-md-12 text-center">
|
||||
Customer References<br/>
|
||||
<small>Trusted by millions worldwide</small>
|
||||
</h1>
|
||||
<div class="col-md-12" id="ref_content">
|
||||
<div class='navbar'>
|
||||
<div>
|
||||
<t t-call="website.pager">
|
||||
<t t-set="classname" t-value="'pull-left'"/>
|
||||
</t>
|
||||
<form action="/customers/" method="get" class="navbar-search pull-right pagination form-inline">
|
||||
<div class="form-group">
|
||||
<input type="text" name="search" class="search-query form-control"
|
||||
placeholder="Search" t-att-value="post.get('search', '')"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div t-foreach="partner_ids" t-as="partner" class="media thumbnail" data-publish="">
|
||||
<t t-call="website.publish_management"><t t-set="object" t-value="partner"/></t>
|
||||
<a class="pull-left" t-attf-href="/customers/#{ partner.id }/">
|
||||
<img class="media-object" t-att-src="partner.img('image_small')"/>
|
||||
</a>
|
||||
<div class="media-body" style="min-height: 64px;">
|
||||
<a class="media-heading" t-attf-href="/customers/#{ partner.id }/"><span t-field="partner.parent_id"/> <span t-field="partner.name"/></a>
|
||||
<div t-field="partner.website_short_description"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<!-- 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>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue