diff --git a/addons/mass_mailing_crm/__init__.py b/addons/mass_mailing_crm/__init__.py new file mode 100644 index 00000000000..dc5e6b693d1 --- /dev/null +++ b/addons/mass_mailing_crm/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models diff --git a/addons/mass_mailing_crm/__manifest__.py b/addons/mass_mailing_crm/__manifest__.py new file mode 100644 index 00000000000..083ebe6240e --- /dev/null +++ b/addons/mass_mailing_crm/__manifest__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +{ + 'name': 'Mass mailing on lead / opportunities', + 'category': 'Hidden', + 'version': '1.0', + 'summary': 'Add lead / opportunities UTM info on mass mailing', + 'description': """UTM and mass mailing on lead / opportunities""", + 'depends': ['crm', 'mass_mailing'], + 'data': [ + 'views/mass_mailing_views.xml', + ], + 'demo': [ + 'data/mass_mailing_demo.xml', + ], + 'auto_install': True, +} diff --git a/addons/mass_mailing_crm/data/mass_mailing_demo.xml b/addons/mass_mailing_crm/data/mass_mailing_demo.xml new file mode 100644 index 00000000000..d96d68d00da --- /dev/null +++ b/addons/mass_mailing_crm/data/mass_mailing_demo.xml @@ -0,0 +1,78 @@ + + + + + Lead Newsletter + in_queue + + + + + + + [] + email + ${object.company_id.email} + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+ Hello
+ + ${object.name} + +
+ ${object.company_id.name} +
+
+
+
+

Dear ${object.name}

+

Great stories have personality. Consider telling a great story that provides personality. Writing a story with personality for potential clients will assist with making a relationship connection. This shows up in small quirks like word choices or phrases. Write from your point of view, not from someone else's experience.

+

Great stories are for everyone even when only written for just one person. If you try to write with a wide general audience in mind, your story will ring false and be bland. No one will be interested. Write for one person. If it’s genuine for the one, it’s genuine for the rest.

+
+
+ ${object.company_id.name}
+
+ ${object.company_id.phone} + % if object.company_id.email + | + + ${object.company_id.email} + + % endif + ${object.company_id.website} + | + + ${object.company_id.website} + + % endif +
+
+
+ Powered by Odoo +
+
+
+
\ No newline at end of file diff --git a/addons/mass_mailing_crm/models/__init__.py b/addons/mass_mailing_crm/models/__init__.py new file mode 100644 index 00000000000..972aef5812b --- /dev/null +++ b/addons/mass_mailing_crm/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import mass_mailing diff --git a/addons/mass_mailing_crm/models/mass_mailing.py b/addons/mass_mailing_crm/models/mass_mailing.py new file mode 100644 index 00000000000..737db75443e --- /dev/null +++ b/addons/mass_mailing_crm/models/mass_mailing.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + + +from odoo import api, fields, models + + +class MassMailing(models.Model): + _name = 'mail.mass_mailing' + _inherit = 'mail.mass_mailing' + + crm_lead_activated = fields.Boolean('Use Leads', compute='_compute_crm_lead_activated') + crm_lead_count = fields.Integer('Lead Count', compute='_compute_crm_lead_count') + crm_opportunities_count = fields.Integer('Opportunities Count', compute='_compute_crm_opportunities_count') + + def _compute_crm_lead_activated(self): + for mass_mailing in self: + mass_mailing.crm_lead_activated = self.env.user.has_group('crm.group_use_lead') + + @api.depends('crm_lead_activated') + def _compute_crm_lead_count(self): + for mass_mailing in self: + if mass_mailing.mailing_model_name != 'crm.lead' or not mass_mailing.crm_lead_activated: + mass_mailing.crm_lead_count = 0 + else: + mass_mailing.crm_lead_count = self.env['crm.lead'].search_count(self._get_crm_utm_domain()) + + @api.depends('crm_lead_activated') + def _compute_crm_opportunities_count(self): + for mass_mailing in self: + if mass_mailing.mailing_model_name != 'crm.lead' or mass_mailing.crm_lead_activated: + mass_mailing.crm_opportunities_count = 0 + else: + mass_mailing.crm_opportunities_count = self.env['crm.lead'].search_count(self._get_crm_utm_domain()) + + @api.multi + def action_redirect_to_leads(self): + action = self.env.ref('crm.crm_lead_all_leads').read()[0] + action['domain'] = self._get_crm_utm_domain() + action['context'] = {'default_type': 'lead'} + return action + + @api.multi + def action_redirect_to_opportunities(self): + action = self.env.ref('crm.crm_lead_opportunities').read()[0] + action['view_mode'] = 'tree,kanban,graph,pivot,form,calendar' + action['domain'] = self._get_crm_utm_domain() + return action + + def _get_crm_utm_domain(self): + res = [] + if self.campaign_id: + res.append(('campaign_id', '=', self.campaign_id.id)) + if self.source_id: + res.append(('source_id', '=', self.source_id.id)) + if self.medium_id: + res.append(('medium_id', '=', self.medium_id.id)) + if not res: + res.append(('1', '=', '0')) + return res diff --git a/addons/mass_mailing_crm/views/mass_mailing_views.xml b/addons/mass_mailing_crm/views/mass_mailing_views.xml new file mode 100644 index 00000000000..889c6ff8529 --- /dev/null +++ b/addons/mass_mailing_crm/views/mass_mailing_views.xml @@ -0,0 +1,27 @@ + + + + mail.mass_mailing.view.form.inherit.crm + mail.mass_mailing + + + + + + + + + + \ No newline at end of file