[FIX] website_crm_partner_assign: fix portal lead/issue to use commercial_partner_id
Before this commit, only partner really assigned to the lead AND with a grade was able to see their leads. Now we check that the top level partner (commercial_partner_id) has a grade, and show all the leads under this commercial_partner_id. Try to get the same behaviour that previous portal backend. opw-688359
This commit is contained in:
@@ -16,17 +16,23 @@ from odoo.addons.website_portal.controllers.main import website_account
|
||||
|
||||
class WebsiteAccount(website_account):
|
||||
|
||||
def get_domain_my_lead(self, user):
|
||||
return [
|
||||
('partner_assigned_id', 'child_of', user.commercial_partner_id.id),
|
||||
('type', '=', 'lead')
|
||||
]
|
||||
|
||||
def get_domain_my_opp(self, user):
|
||||
return [
|
||||
('partner_assigned_id', 'child_of', user.commercial_partner_id.id),
|
||||
('type', '=', 'opportunity')
|
||||
]
|
||||
|
||||
@http.route()
|
||||
def account(self):
|
||||
response = super(WebsiteAccount, self).account()
|
||||
lead_count = request.env['crm.lead'].search_count([
|
||||
('partner_assigned_id', '=', request.env.user.partner_id.id),
|
||||
('type', '=', 'lead')
|
||||
])
|
||||
opp_count = request.env['crm.lead'].search_count([
|
||||
('partner_assigned_id', '=', request.env.user.partner_id.id),
|
||||
('type', '=', 'opportunity')
|
||||
])
|
||||
lead_count = request.env['crm.lead'].search_count(self.get_domain_my_lead(request.env.user))
|
||||
opp_count = request.env['crm.lead'].search_count(self.get_domain_my_opp(request.env.user))
|
||||
response.qcontext.update({'lead_count': lead_count, 'opp_count': opp_count})
|
||||
return response
|
||||
|
||||
@@ -34,7 +40,7 @@ class WebsiteAccount(website_account):
|
||||
def portal_my_leads(self, page=1, date_begin=None, date_end=None, lead=None, sortby=None, **kw):
|
||||
values = self._prepare_portal_layout_values()
|
||||
CrmLead = request.env['crm.lead']
|
||||
domain = [('partner_assigned_id', '=', request.env.user.partner_id.id), ('type', '=', 'lead')]
|
||||
domain = self.get_domain_my_lead(request.env.user)
|
||||
|
||||
sortings = {
|
||||
'date': {'label': _('Newest'), 'order': 'create_date desc'},
|
||||
@@ -77,7 +83,7 @@ class WebsiteAccount(website_account):
|
||||
def portal_my_opportunities(self, page=1, date_begin=None, date_end=None, opportunity=None, sortby=None, **kw):
|
||||
values = self._prepare_portal_layout_values()
|
||||
CrmLead = request.env['crm.lead']
|
||||
domain = [('partner_assigned_id', '=', request.env.user.partner_id.id), ('type', '=', 'opportunity')]
|
||||
domain = self.get_domain_my_opp(request.env.user)
|
||||
|
||||
today = fields.Date.today()
|
||||
this_week_end_date = fields.Date.to_string(fields.Date.from_string(today) + datetime.timedelta(days=7))
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
</template>
|
||||
<template id="portal_my_home_menu_lead" name="Portal layout : lead menu entry" inherit_id="website_portal.portal_layout" priority="22">
|
||||
<xpath expr="//ul[contains(@class,'o_portal_submenu')]" position="inside">
|
||||
<t t-if="user.partner_id.grade_id.id != False">
|
||||
<t t-if="user.commercial_partner_id.grade_id">
|
||||
<li t-att-class="page_name == 'lead' and 'active'">
|
||||
<a href="/my/leads">Leads</a>
|
||||
</li>
|
||||
@@ -207,7 +207,7 @@
|
||||
|
||||
<template id="portal_my_home_lead" name="Portal My Home : lead entries" inherit_id="website_portal.portal_my_home" priority="22">
|
||||
<xpath expr="//div[contains(@class,'o_my_home_content')]" position="inside">
|
||||
<t t-if="user.partner_id.grade_id.id != False">
|
||||
<t t-if="user.commercial_partner_id.grade_id">
|
||||
<h3 class="page-header">
|
||||
<a href="/my/leads">Your Leads
|
||||
<small class="ml8">
|
||||
@@ -259,20 +259,18 @@
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr class="active">
|
||||
<th class="col-md-5">Name</th>
|
||||
<th class="col-xs-2">Date</th>
|
||||
<th class="col-xs-5">Name</th>
|
||||
<th>Contact Name</th>
|
||||
<th>Stage</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr t-foreach="leads" t-as="lead">
|
||||
<td><span t-field="lead.create_date" t-field-options='{"widget": "date"}' /></td>
|
||||
<td>
|
||||
<a t-attf-href="/my/lead/#{lead.id}"><span t-field="lead.name"/></a>
|
||||
</td>
|
||||
<td><span t-field="lead.contact_name" /></td>
|
||||
<td>
|
||||
<span class="label label-primary" title="Current stage of the lead" t-esc="lead.stage_id.name" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user