[IMP] "website_crm_partner_assign" compatible with Multi-Website
This commit is contained in:
parent
5c7099863d
commit
7366c0bd65
@ -185,14 +185,14 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
|
|||||||
yield {'loc': '/partners'}
|
yield {'loc': '/partners'}
|
||||||
|
|
||||||
Grade = env['res.partner.grade']
|
Grade = env['res.partner.grade']
|
||||||
dom = [('website_published', '=', True)]
|
dom = [('website_published', '=', True), ('website_ids', 'in', request.website.id)]
|
||||||
dom += sitemap_qs2dom(qs=qs, route='/partners/grade/', field=Grade._rec_name)
|
dom += sitemap_qs2dom(qs=qs, route='/partners/grade/', field=Grade._rec_name)
|
||||||
for grade in env['res.partner.grade'].search(dom):
|
for grade in env['res.partner.grade'].search(dom):
|
||||||
loc = '/partners/grade/%s' % slug(grade)
|
loc = '/partners/grade/%s' % slug(grade)
|
||||||
if not qs or qs.lower() in loc:
|
if not qs or qs.lower() in loc:
|
||||||
yield {'loc': loc}
|
yield {'loc': loc}
|
||||||
|
|
||||||
partners_dom = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True), ('grade_id.website_published', '=', True)]
|
partners_dom = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True), ('website_ids', 'in', request.website.id), ('grade_id.website_published', '=', True)]
|
||||||
dom += sitemap_qs2dom(qs=qs, route='/partners/country/')
|
dom += sitemap_qs2dom(qs=qs, route='/partners/country/')
|
||||||
countries = env['res.partner'].sudo().read_group(partners_dom, fields=['id', 'country_id'], groupby='country_id')
|
countries = env['res.partner'].sudo().read_group(partners_dom, fields=['id', 'country_id'], groupby='country_id')
|
||||||
for country in countries:
|
for country in countries:
|
||||||
@ -221,7 +221,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
|
|||||||
|
|
||||||
base_partner_domain = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True)]
|
base_partner_domain = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True)]
|
||||||
if not request.env['res.users'].has_group('website.group_website_publisher'):
|
if not request.env['res.users'].has_group('website.group_website_publisher'):
|
||||||
base_partner_domain += [('grade_id.website_published', '=', True)]
|
base_partner_domain += [('grade_id.website_published', '=', True), ('grade_id.website_ids', 'in', request.website.id)]
|
||||||
if search:
|
if search:
|
||||||
base_partner_domain += ['|', ('name', 'ilike', search), ('website_description', 'ilike', search)]
|
base_partner_domain += ['|', ('name', 'ilike', search), ('website_description', 'ilike', search)]
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
|
|||||||
if partner_id:
|
if partner_id:
|
||||||
partner = request.env['res.partner'].sudo().browse(partner_id)
|
partner = request.env['res.partner'].sudo().browse(partner_id)
|
||||||
is_website_publisher = request.env['res.users'].has_group('website.group_website_publisher')
|
is_website_publisher = request.env['res.users'].has_group('website.group_website_publisher')
|
||||||
if partner.exists() and (partner.website_published or is_website_publisher):
|
if partner.exists() and ((partner.website_published and request.website in partner.website_ids) or is_website_publisher):
|
||||||
values = {
|
values = {
|
||||||
'main_object': partner,
|
'main_object': partner,
|
||||||
'partner': partner,
|
'partner': partner,
|
||||||
|
@ -3,15 +3,19 @@
|
|||||||
<data noupdate="1">
|
<data noupdate="1">
|
||||||
<record id="website_crm_partner_assign.res_partner_grade_platinium" model="res.partner.grade">
|
<record id="website_crm_partner_assign.res_partner_grade_platinium" model="res.partner.grade">
|
||||||
<field name="website_published" eval="True" />
|
<field name="website_published" eval="True" />
|
||||||
|
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="website_crm_partner_assign.res_partner_grade_gold" model="res.partner.grade">
|
<record id="website_crm_partner_assign.res_partner_grade_gold" model="res.partner.grade">
|
||||||
<field name="website_published" eval="True" />
|
<field name="website_published" eval="True" />
|
||||||
|
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="website_crm_partner_assign.res_partner_grade_silver" model="res.partner.grade">
|
<record id="website_crm_partner_assign.res_partner_grade_silver" model="res.partner.grade">
|
||||||
<field name="website_published" eval="True" />
|
<field name="website_published" eval="True" />
|
||||||
|
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="website_crm_partner_assign.res_partner_grade_bronze" model="res.partner.grade">
|
<record id="website_crm_partner_assign.res_partner_grade_bronze" model="res.partner.grade">
|
||||||
<field name="website_published" eval="True" />
|
<field name="website_published" eval="True" />
|
||||||
|
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="base.partner_demo_portal" model="res.partner">
|
<record id="base.partner_demo_portal" model="res.partner">
|
||||||
<field name="grade_id" ref="website_crm_partner_assign.res_partner_grade_platinium"/>
|
<field name="grade_id" ref="website_crm_partner_assign.res_partner_grade_platinium"/>
|
||||||
|
@ -15,6 +15,11 @@ class ResPartnerGrade(models.Model):
|
|||||||
name = fields.Char('Level Name', translate=True)
|
name = fields.Char('Level Name', translate=True)
|
||||||
partner_weight = fields.Integer('Level Weight', default=1,
|
partner_weight = fields.Integer('Level Weight', default=1,
|
||||||
help="Gives the probability to assign a lead to this partner. (0 means no assignation.)")
|
help="Gives the probability to assign a lead to this partner. (0 means no assignation.)")
|
||||||
|
website_ids = fields.Many2many('website', 'website_partner_grade_pub_rel',
|
||||||
|
'website_id', 'partner_grade_id',
|
||||||
|
string='Websites', copy=False,
|
||||||
|
help='List of websites in which '
|
||||||
|
'Partner Grade is published.')
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _compute_website_url(self):
|
def _compute_website_url(self):
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
<field name="partner_weight"/>
|
<field name="partner_weight"/>
|
||||||
<field name="sequence"/>
|
<field name="sequence"/>
|
||||||
<field name="active"/>
|
<field name="active"/>
|
||||||
|
<field name="website_ids" widget="many2many_tags"/>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
|
@ -162,7 +162,7 @@
|
|||||||
|
|
||||||
<template id="grade_in_detail" inherit_id="website_partner.partner_detail">
|
<template id="grade_in_detail" inherit_id="website_partner.partner_detail">
|
||||||
<xpath expr="//*[@id='partner_name']" position="after">
|
<xpath expr="//*[@id='partner_name']" position="after">
|
||||||
<h3 class="col-md-12 text-center text-muted" t-if="partner.grade_id and partner.grade_id.website_published">
|
<h3 class="col-md-12 text-center text-muted" t-if="partner.grade_id and partner.grade_id.website_published and website in partner.grade_id.website_published">
|
||||||
<span t-field="partner.grade_id"/> Partner</h3>
|
<span t-field="partner.grade_id"/> Partner</h3>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
@ -171,7 +171,7 @@
|
|||||||
<t t-if="any([p.website_published for p in partner.implemented_partner_ids])">
|
<t t-if="any([p.website_published for p in partner.implemented_partner_ids])">
|
||||||
<h3 id="references">References</h3>
|
<h3 id="references">References</h3>
|
||||||
<div t-foreach="partner.implemented_partner_ids" t-as="reference" class="media">
|
<div t-foreach="partner.implemented_partner_ids" t-as="reference" class="media">
|
||||||
<t t-if="reference.website_published">
|
<t t-if="website in reference.website_ids and reference.website_published">
|
||||||
<a class="pull-left" t-attf-href="/customers/#{slug(reference)}">
|
<a class="pull-left" t-attf-href="/customers/#{slug(reference)}">
|
||||||
<span t-field="reference.image_small" t-options='{"widget": "image", "class": "center-block"}'/>
|
<span t-field="reference.image_small" t-options='{"widget": "image", "class": "center-block"}'/>
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user