First version of groupeurd_newsletter module.

See module description in __openerp__.py for more details.
This commit is contained in:
Olivier Sarrat 2016-10-14 09:44:01 +02:00
parent 6116b92696
commit 388bd038b6
13 changed files with 1428 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
import models
import controllers

Binary file not shown.

View File

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
{
'name': "groupeurd_newsletter",
'summary': """
Adaptation du module "mass_mailing" pour les besoins spécifiques du Groupe URD.""",
'description': """
- Renommer "contacts" en "abonnés" pour liste de diffusion
- Renomer menu "Marketing" en "Listes de diffusion"
- Unicité de l'abonné dans chaque liste
- Droits d'utilisateur pour limiter accès à uniquement publipostages et listes de diffusion
- Retirer droit de suppression d'abonné au profil Responsable Marketing
- Retirer la gestion des nom des abonnés (dans la liste ou dans le formulaire)
- Ajouter un champ "unsubscribed_by_odoo_user" qui sera manipulé pour les désincriptions par interface
- Afficher champ create_uid pour savoir provenance des contacts
- Ne garder que les modèles de courriel de newsletter dans Publipostages/Modèles de courriel
- Retrait insertion automatique lien désinscription
- Message de confirmation de désincription plus verbeux
""",
'author': "Groupe URD",
'website': "http://www.urd.org",
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
# for the full list
'category': 'Marketing',
'version': '0.1',
# any module necessary for this one to work correctly
'depends': ['base','mass_mailing','marketing'],
# always loaded
'data': [
'security/ir.model.access.csv',
'security/security.xml',
'actions-menus.xml',
'views.xml',
],
# only loaded in demonstration mode (not used in this groupeurd_newsletter module)
'demo': [
#'demo.xml',
],
}

View File

@ -0,0 +1,20 @@
<openerp>
<data>
<!--
Limit email templates visible to mailing list templates in Marketing/EmailTemplates
-->
<record model="ir.actions.act_window" id="mass_mailing.action_email_template_marketing">
<field name="name">Templates</field>
<field name="res_model">email.template</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="context">{
'form_view_ref': 'mass_mailing.email_template_form_minimal',
'default_use_default_to': True,
}</field>
<field name="domain">[('model_id.model','=','mail.mass_mailing.contact')]</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
from openerp import http, SUPERUSER_ID
from openerp.http import request
from openerp.addons.mass_mailing.controllers.main import MassMailController
from openerp.tools.translate import _
class GroupeURD_Newsletter(http.Controller):
@http.route('/newsletter/html_version_<massmailing_id>', auth='public')
def view_newsletter_html_version(self, massmailing_id):
mass_mailing = http.request.env['mail.mass_mailing'].search([('id','=',massmailing_id)])
return mass_mailing.body_html
##class GroupeURD_MassMailController(MassMailController):
##
## #Add nicer message on unsubscribe
## @http.route(['/mail/mailing/<int:mailing_id>/unsubscribe'], type='http', auth='none')
## def mailing(self, mailing_id, email=None, res_id=None, **post):
## sup_Controller = super(MassMailController, self)
## basic_result_message = sup_Controller.mailing(mailing_id, email, res_id, **post)
##
## # part of the method added to have a nicer message
## res_contact = http.request.env['mail.mass_mailing.contact'].search([('id','=',res_id)])
## html_result_message = '<div style="text-align:center">'
## if basic_result_message == 'OK':
## html_result_message += _("The following email address has been successfully unsubscribed from the list")
## html_result_message += ' "%s" : ' % res_contact.list_id.name
## html_result_message += email
## else:
## html_result_message += _("Unable to unsubscribe the following email address from the list")
## html_result_message += ' "%s" : ' % res_contact.list_id.name
## html_result_message += email
## html_result_message += '</div>'
## return html_result_message

Binary file not shown.

View File

@ -0,0 +1,25 @@
<openerp>
<data>
<!-- -->
<!-- <record id="object0" model="groupeurd_newsletter.groupeurd_newsletter"> -->
<!-- <field name="name">Object 0</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object1" model="groupeurd_newsletter.groupeurd_newsletter"> -->
<!-- <field name="name">Object 1</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object2" model="groupeurd_newsletter.groupeurd_newsletter"> -->
<!-- <field name="name">Object 2</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object3" model="groupeurd_newsletter.groupeurd_newsletter"> -->
<!-- <field name="name">Object 3</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object4" model="groupeurd_newsletter.groupeurd_newsletter"> -->
<!-- <field name="name">Object 4</field> -->
<!-- </record> -->
<!-- -->
</data>
</openerp>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api
from openerp.osv import osv
from openerp.tools.translate import _
# Overrides mass mailing Contact for this module purpose
class contact(models.Model):
_name = "mail.mass_mailing.contact"
_inherit = "mail.mass_mailing.contact"
unsubscription_date = fields.Date(string="Unsubscription date")
unsubscribed_by_odoo_user = fields.Many2one("res.users", string="Unsubscribed by this Odoo user")
_sql_constraints = [
('email_list_unique',
'unique (email, list_id)',
_('Subscriber already registered for this mailing list.')
)]
@api.onchange("opt_out")
def on_change_opt_out(self):
if self.opt_out:
self.unsubscription_date = fields.Datetime.now()
self.unsubscribed_by_odoo_user = self.env.user
else:
self.unsubscription_date = None
self.unsubscribed_by_odoo_user = None
class MailMail(osv.Model):
"""Add the mass mailing campaign data to mail"""
_name = 'mail.mail'
_inherit = ['mail.mail']
def _get_unsubscribe_url(self, cr, uid, mail, email_to, msg=None, context=None):
return None
#class MassMailing(osv.Model):
#_name = "mail.mass_mailing"
#_inherit = "mail.mass_mailing"
#def _get_mailing_model(self, cr, uid, context=None):
# res = super(MassMailing, self)._get_mailing_model(cr, uid, context)
# res.append(('mail.tracking.email', _('Email Tracking')))
# print res
# return res
# indirections for inheritance
#_mailing_model = lambda self, *args, **kwargs: self._get_mailing_model_groupeurd(*args, **kwargs)
#_columns = {
# recipients
# 'mailing_model': fields.selection(_mailing_model, string='Recipients Model', required=True)
#}
#def action_edit_html(self, cr, uid, ids, context=None):
# if not len(ids) == 1:
# raise ValueError('One and only one ID allowed for this action')
# mail = self.browse(cr, uid, ids[0], context=context)
# if mail.mailing_model == 'mail.mass_mailing.contact' :
# template_model = 'mail.tracking.email'
# else:
# template_model = mail.mailing_model
#url = '/website_mail/email_designer?model=mail.mass_mailing&res_id=%d&template_model=%s&return_action=%d&enable_editor=1' % (ids[0], mail.mailing_model, context['params']['action'])
# url = '/website_mail/email_designer?model=mail.mass_mailing&res_id=%d&template_model=%s&return_action=%d&enable_editor=1' % (ids[0], template_model, context['params']['action'])
# return {
# 'name': _('Open with Visual Editor'),
# 'type': 'ir.actions.act_url',
# 'url': url,
# 'target': 'self',
# }

Binary file not shown.

View File

@ -0,0 +1,12 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
mass_mailing_manager,mass_mailing_manager,mass_mailing.model_mail_mass_mailing,marketing.group_marketing_manager,1,1,1,1
mass_mailing_list_manager,mass_mailing_list_manager,mass_mailing.model_mail_mass_mailing_list,marketing.group_marketing_manager,1,1,1,1
mass_mailing_contact_manager,mass_mailing_contact_manager,mass_mailing.model_mail_mass_mailing_contact,marketing.group_marketing_manager,1,1,1,0
email_template_manager,email_template_manager,email_template.model_email_template,marketing.group_marketing_manager,1,1,1,1
mass_mailing_user,mass_mailing_user,mass_mailing.model_mail_mass_mailing,marketing.group_marketing_user,1,1,1,0
mass_mailing_list_user,mass_mailing_list_user,mass_mailing.model_mail_mass_mailing_list,marketing.group_marketing_user,1,1,0,0
mass_mailing_contact_user,mass_mailing_contact_user,mass_mailing.model_mail_mass_mailing_contact,marketing.group_marketing_user,1,1,1,0
email_template_user,email_template_user,email_template.model_email_template,marketing.group_marketing_user,0,0,0,0
mass_mailing.access_mass_mailing_contact,mail.mass_mailing.contact,mass_mailing.model_mail_mass_mailing_contact,base.group_user,1,1,1,0
mass_mailing.access_mass_mailing_list,mail.mass_mailing.list,mass_mailing.model_mail_mass_mailing_list,base.group_user,1,1,0,0
mass_mailing.access_mass_mailing,mail.mass_mailing,mass_mailing.model_mail_mass_mailing,base.group_user,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 mass_mailing_manager mass_mailing_manager mass_mailing.model_mail_mass_mailing marketing.group_marketing_manager 1 1 1 1
3 mass_mailing_list_manager mass_mailing_list_manager mass_mailing.model_mail_mass_mailing_list marketing.group_marketing_manager 1 1 1 1
4 mass_mailing_contact_manager mass_mailing_contact_manager mass_mailing.model_mail_mass_mailing_contact marketing.group_marketing_manager 1 1 1 0
5 email_template_manager email_template_manager email_template.model_email_template marketing.group_marketing_manager 1 1 1 1
6 mass_mailing_user mass_mailing_user mass_mailing.model_mail_mass_mailing marketing.group_marketing_user 1 1 1 0
7 mass_mailing_list_user mass_mailing_list_user mass_mailing.model_mail_mass_mailing_list marketing.group_marketing_user 1 1 0 0
8 mass_mailing_contact_user mass_mailing_contact_user mass_mailing.model_mail_mass_mailing_contact marketing.group_marketing_user 1 1 1 0
9 email_template_user email_template_user email_template.model_email_template marketing.group_marketing_user 0 0 0 0
10 mass_mailing.access_mass_mailing_contact mail.mass_mailing.contact mass_mailing.model_mail_mass_mailing_contact base.group_user 1 1 1 0
11 mass_mailing.access_mass_mailing_list mail.mass_mailing.list mass_mailing.model_mail_mass_mailing_list base.group_user 1 1 0 0
12 mass_mailing.access_mass_mailing mail.mass_mailing mass_mailing.model_mail_mass_mailing base.group_user 1 0 0 0

View File

@ -0,0 +1,32 @@
<openerp>
<data>
<!--
Rule to ban everyone from removing a contact from a mailing list
model="ir.rule" => indicates that it is a permission rule
field model_id => gives the object on which the rule is applied
fields perm_* => indicate the permissions which will be given (here: only "unlink")
field domain_force => a condition for who will get those given permissions (here: an impossible condition, so permission given to no one (except root admin))
-->
<record id="mass_mailing_contact_unlink_impossible" model="ir.rule">
<field name="name">Impossible for no one to remove a contact from mailing list</field>
<field name="model_id" ref="mass_mailing.model_mail_mass_mailing_contact" />
<!-- Specifies that this rule is global and applicable for all users and groups -->
<field name="global" eval="1" />
<field name="perm_read" eval="0" />
<field name="perm_write" eval="0" />
<field name="perm_create" eval="0" />
<field name="perm_unlink" eval="1" />
<field name="domain_force">[('create_uid','=','-1')]</field>
</record>
<!-- Limit visibility of menu item "Modèles de courriel" in "Publipostage" only to marketing managers -->
<record id="mass_mailing.menu_email_template" model="ir.ui.menu">
<field name="groups_id" eval="[(6,0,[ref('marketing.group_marketing_manager')])]" />
</record>
</data>
</openerp>

View File

@ -0,0 +1,28 @@
<openerp>
<data>
<record model="ir.ui.view" id="noname_view_mail_mass_mailing_contact_tree">
<field name="name">mail.mass_mailing.contact.tree</field>
<field name="model">mail.mass_mailing.contact</field>
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_contact_tree" />
<field name="arch" type="xml">
<field name="name" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="list_id" position="after">
<field name="create_uid" string="Source" readonly="1" />
</field>
<!-- The fields "unsubscribed_by_odoo_user" & "unsubscription_date" must be displayed so that
the new function on_change_opt_out() can edit their value in the UI
Note: the "on_change" functions can only work in the UI
-->
<field name="opt_out" position="after">
<field name="unsubscription_date" invisible="1"/>
<field name="unsubscribed_by_odoo_user" invisible="1" />
</field>
</field>
</record>
</data>
</openerp>