From 7366c0bd652cf5090b7f8ec96578e62f87ef1ab2 Mon Sep 17 00:00:00 2001 From: Kaushal Prajapati Date: Mon, 25 Dec 2017 10:54:55 +0530 Subject: [PATCH] [IMP] "website_crm_partner_assign" compatible with Multi-Website --- addons/website_crm_partner_assign/controllers/main.py | 8 ++++---- .../data/res_partner_grade_demo.xml | 4 ++++ addons/website_crm_partner_assign/models/res_partner.py | 5 +++++ .../views/res_partner_views.xml | 1 + .../views/website_crm_partner_assign_templates.xml | 4 ++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/addons/website_crm_partner_assign/controllers/main.py b/addons/website_crm_partner_assign/controllers/main.py index eb9c8bc1..34640844 100644 --- a/addons/website_crm_partner_assign/controllers/main.py +++ b/addons/website_crm_partner_assign/controllers/main.py @@ -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, diff --git a/addons/website_crm_partner_assign/data/res_partner_grade_demo.xml b/addons/website_crm_partner_assign/data/res_partner_grade_demo.xml index c24d0a3c..e1b963b1 100644 --- a/addons/website_crm_partner_assign/data/res_partner_grade_demo.xml +++ b/addons/website_crm_partner_assign/data/res_partner_grade_demo.xml @@ -3,15 +3,19 @@ + + + + diff --git a/addons/website_crm_partner_assign/models/res_partner.py b/addons/website_crm_partner_assign/models/res_partner.py index 033ff172..745ac480 100644 --- a/addons/website_crm_partner_assign/models/res_partner.py +++ b/addons/website_crm_partner_assign/models/res_partner.py @@ -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): diff --git a/addons/website_crm_partner_assign/views/res_partner_views.xml b/addons/website_crm_partner_assign/views/res_partner_views.xml index eaed61e2..60615ef9 100644 --- a/addons/website_crm_partner_assign/views/res_partner_views.xml +++ b/addons/website_crm_partner_assign/views/res_partner_views.xml @@ -71,6 +71,7 @@ + diff --git a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml index d0df06c3..74e659e8 100644 --- a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml +++ b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml @@ -162,7 +162,7 @@ @@ -171,7 +171,7 @@

References

- +