[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'}
|
||||
|
||||
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)
|
||||
for grade in env['res.partner.grade'].search(dom):
|
||||
loc = '/partners/grade/%s' % slug(grade)
|
||||
if not qs or qs.lower() in 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/')
|
||||
countries = env['res.partner'].sudo().read_group(partners_dom, fields=['id', 'country_id'], groupby='country_id')
|
||||
for country in countries:
|
||||
@ -221,7 +221,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
|
||||
|
||||
base_partner_domain = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True)]
|
||||
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:
|
||||
base_partner_domain += ['|', ('name', 'ilike', search), ('website_description', 'ilike', search)]
|
||||
|
||||
@ -327,7 +327,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
|
||||
if partner_id:
|
||||
partner = request.env['res.partner'].sudo().browse(partner_id)
|
||||
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 = {
|
||||
'main_object': partner,
|
||||
'partner': partner,
|
||||
|
@ -3,15 +3,19 @@
|
||||
<data noupdate="1">
|
||||
<record id="website_crm_partner_assign.res_partner_grade_platinium" model="res.partner.grade">
|
||||
<field name="website_published" eval="True" />
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="website_crm_partner_assign.res_partner_grade_gold" model="res.partner.grade">
|
||||
<field name="website_published" eval="True" />
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="website_crm_partner_assign.res_partner_grade_silver" model="res.partner.grade">
|
||||
<field name="website_published" eval="True" />
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="website_crm_partner_assign.res_partner_grade_bronze" model="res.partner.grade">
|
||||
<field name="website_published" eval="True" />
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="base.partner_demo_portal" model="res.partner">
|
||||
<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)
|
||||
partner_weight = fields.Integer('Level Weight', default=1,
|
||||
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
|
||||
def _compute_website_url(self):
|
||||
|
@ -71,6 +71,7 @@
|
||||
<field name="partner_weight"/>
|
||||
<field name="sequence"/>
|
||||
<field name="active"/>
|
||||
<field name="website_ids" widget="many2many_tags"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
@ -162,7 +162,7 @@
|
||||
|
||||
<template id="grade_in_detail" inherit_id="website_partner.partner_detail">
|
||||
<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>
|
||||
</xpath>
|
||||
</template>
|
||||
@ -171,7 +171,7 @@
|
||||
<t t-if="any([p.website_published for p in partner.implemented_partner_ids])">
|
||||
<h3 id="references">References</h3>
|
||||
<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)}">
|
||||
<span t-field="reference.image_small" t-options='{"widget": "image", "class": "center-block"}'/>
|
||||
</a>
|
||||
|
Loading…
Reference in New Issue
Block a user