diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml
index c2788f27c49..11ea2253821 100644
--- a/addons/account/report/account_invoice_report_view.xml
+++ b/addons/account/report/account_invoice_report_view.xml
@@ -117,7 +117,10 @@
%s
%s
') % ( + helper_header, helper_message, + ), 'context': dict(self._context, create=False) } @@ -566,28 +574,45 @@ class MassMailing(models.Model): return self._action_view_documents_filtered('delivered') def _action_view_documents_filtered(self, view_filter): - if view_filter in ('reply', 'bounce'): + model_name = self.env['ir.model']._get(self.mailing_model_real).display_name + helper_header = None + helper_message = None + if view_filter == 'reply': found_traces = self.mailing_trace_ids.filtered(lambda trace: trace.trace_status == view_filter) + helper_header = _("No %s replied to your mailing yet!", model_name) + helper_message = _("To track how many replies this mailing gets, make sure " + "its reply-to address belongs to this database.") + elif view_filter == 'bounce': + found_traces = self.mailing_trace_ids.filtered(lambda trace: trace.trace_status == view_filter) + helper_header = _("No %s address bounced yet!", model_name) + helper_message = _("Bounce happens when a mailing cannot be delivered (fake address, " + "server issues, ...). Check each record to see what went wrong.") elif view_filter == 'open': found_traces = self.mailing_trace_ids.filtered(lambda trace: trace.trace_status in ('open', 'reply')) - elif view_filter == 'click': - found_traces = self.mailing_trace_ids.filtered(lambda trace: trace.links_click_datetime) + helper_header = _("No %s opened your mailing yet!", model_name) + helper_message = _("Come back once your mailing has been sent to track who opened your mailing.") elif view_filter == 'delivered': found_traces = self.mailing_trace_ids.filtered(lambda trace: trace.trace_status in ('sent', 'open', 'reply')) + helper_header = _("No %s received your mailing yet!", model_name) + helper_message = _("Wait until your mailing has been sent to check how many recipients you managed to reach.") elif view_filter == 'sent': found_traces = self.mailing_trace_ids.filtered(lambda trace: trace.sent_datetime) else: found_traces = self.env['mailing.trace'] res_ids = found_traces.mapped('res_id') - model_name = self.env['ir.model']._get(self.mailing_model_real).display_name - return { + action = { 'name': model_name, 'type': 'ir.actions.act_window', 'view_mode': 'tree', 'res_model': self.mailing_model_real, 'domain': [('id', 'in', res_ids)], - 'context': dict(self._context, create=False) + 'context': dict(self._context, create=False), } + if helper_header and helper_message: + action['help'] = Markup('%s
%s
') % ( + helper_header, helper_message, + ), + return action def update_opt_out(self, email, list_ids, value): if len(list_ids) > 0: diff --git a/addons/mass_mailing_crm/models/mailing_mailing.py b/addons/mass_mailing_crm/models/mailing_mailing.py index b804327242a..a2796d529f4 100644 --- a/addons/mass_mailing_crm/models/mailing_mailing.py +++ b/addons/mass_mailing_crm/models/mailing_mailing.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from markupsafe import Markup from odoo import fields, models, _, tools @@ -9,27 +10,40 @@ class MassMailing(models.Model): _inherit = 'mailing.mailing' use_leads = fields.Boolean('Use Leads', compute='_compute_use_leads') - crm_lead_count = fields.Integer('Leads/Opportunities Count', groups='sales_team.group_sale_salesman', compute='_compute_crm_lead_count') + crm_lead_count = fields.Integer('Leads/Opportunities Count', compute='_compute_crm_lead_count') def _compute_use_leads(self): self.use_leads = self.env.user.has_group('crm.group_use_lead') def _compute_crm_lead_count(self): - lead_data = self.env['crm.lead'].with_context(active_test=False).read_group( + lead_data = self.env['crm.lead'].with_context(active_test=False).sudo().read_group( [('source_id', 'in', self.source_id.ids)], - ['source_id'], ['source_id'] + ['source_id'], ['source_id'], ) mapped_data = {datum['source_id'][0]: datum['source_id_count'] for datum in lead_data} for mass_mailing in self: mass_mailing.crm_lead_count = mapped_data.get(mass_mailing.source_id.id, 0) def action_redirect_to_leads_and_opportunities(self): - view = 'crm.crm_lead_all_leads' if self.use_leads else 'crm.crm_lead_opportunities' - action = self.env.ref(view).sudo().read()[0] - action['view_mode'] = 'tree,kanban,graph,pivot,form,calendar' - action['domain'] = [('source_id', 'in', self.source_id.ids)] - action['context'] = {'active_test': False, 'create': False} - return action + text = _("Leads") if self.use_leads else _("Opportunities") + helper_header = _("No %s yet!", text) + helper_message = _("Note that Odoo cannot track replies if they are sent towards email addresses to this database.") + return { + 'context': { + 'active_test': False, + 'create': False, + 'search_default_group_by_create_date_day': True, + 'crm_lead_view_hide_month': True, + }, + 'domain': [('source_id', 'in', self.source_id.ids)], + 'help': Markup('%s
%s
') % ( + helper_header, helper_message, + ), + 'name': _("Leads Analysis"), + 'res_model': 'crm.lead', + 'type': 'ir.actions.act_window', + 'view_mode': 'graph,pivot,tree,form', + } def _prepare_statistics_email_values(self): self.ensure_one() diff --git a/addons/mass_mailing_crm/views/mailing_mailing_views.xml b/addons/mass_mailing_crm/views/mailing_mailing_views.xml index dc75114a7cb..c57c6837559 100644 --- a/addons/mass_mailing_crm/views/mailing_mailing_views.xml +++ b/addons/mass_mailing_crm/views/mailing_mailing_views.xml @@ -10,7 +10,6 @@ type="object" icon="fa-star" class="oe_stat_button" - groups="sales_team.group_sale_salesman" attrs="{'invisible': [('state', '=', 'draft')]}">