Skip to content
Permalink
Browse files

[IMP] mass_mailing: create the pivot view and update the values of gr…

…aph view.

- The purpose of this commit is, graph views does not contain the right measures and pivot view is not there.
- Earlier, the following fields are non-storable (sent, received, opened, replied, clicks, bounced) and those fields can not be shown in graph because graph view perform aggregations on database values, they do not work with non-storable computed fields. So, to overcome from this, we make the fields storable.

Task Id #1936692
  • Loading branch information...
rja-odoo committed Feb 20, 2019
1 parent 20e48b8 commit 6145f910117b93156756298c8b80cd1d3b029f33
Showing with 25 additions and 7 deletions.
  1. +7 −6 addons/mass_mailing/models/mass_mailing.py
  2. +18 −1 addons/mass_mailing/views/mass_mailing_views.xml
@@ -498,12 +498,12 @@ def default_get(self, fields):
scheduled = fields.Integer(compute="_compute_statistics")
expected = fields.Integer(compute="_compute_statistics")
ignored = fields.Integer(compute="_compute_statistics")
sent = fields.Integer(compute="_compute_statistics")
delivered = fields.Integer(compute="_compute_statistics")
opened = fields.Integer(compute="_compute_statistics")
clicked = fields.Integer(compute="_compute_statistics")
replied = fields.Integer(compute="_compute_statistics")
bounced = fields.Integer(compute="_compute_statistics")
sent = fields.Integer(compute="_compute_statistics", store=True)
delivered = fields.Integer(compute="_compute_statistics", store=True)
opened = fields.Integer(compute="_compute_statistics", store=True)
clicked = fields.Integer(compute="_compute_statistics", store=True)
replied = fields.Integer(compute="_compute_statistics", store=True)
bounced = fields.Integer(compute="_compute_statistics", store=True)
failed = fields.Integer(compute="_compute_statistics")
received_ratio = fields.Integer(compute="_compute_statistics", string='Received Ratio')
opened_ratio = fields.Integer(compute="_compute_statistics", string='Opened Ratio')
@@ -534,6 +534,7 @@ def _compute_model(self):
for record in self:
record.mailing_model_real = (record.mailing_model_name != 'mail.mass_mailing.list') and record.mailing_model_name or 'mail.mass_mailing.contact'

@api.depends('statistics_ids.sent', 'statistics_ids.bounced', 'statistics_ids.opened', 'statistics_ids.clicked', 'statistics_ids.replied')
def _compute_statistics(self):
""" Compute statistics of the mass mailing """
self.env.cr.execute("""
@@ -761,15 +761,32 @@
<field name="arch" type="xml">
<graph string="Mailing" type="bar">
<field name="state" type="row"/>
<field name="sent" type="measure"/>
<field name="delivered" type="measure"/>
<field name="opened" type="measure"/>
<field name="replied" type="measure"/>
<field name="clicked" type="measure"/>
<field name="bounced" type="measure"/>
</graph>
</field>
</record>

<record id="view_mail_mass_mailing_pivot" model="ir.ui.view">
<field name="name">mail.mass_mailing.pivot</field>
<field name="model">mail.mass_mailing</field>
<field name="arch" type="xml">
<pivot string="Mass Mail" disable_linking="True">
<field name="mass_mailing_campaign_id" type="row"/>
<field name="state" type="col"/>
</pivot>
</field>
</record>

<record id="action_view_mass_mailings" model="ir.actions.act_window">
<field name="name">Mailings</field>
<field name="res_model">mail.mass_mailing</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form,graph</field>
<field name="view_mode">kanban,tree,form,graph,pivot</field>
<field name="context">{
'search_default_assigned_to_me': 1,
'default_user_id': uid,

0 comments on commit 6145f91

Please sign in to comment.
You can’t perform that action at this time.