Browse Source

[10.0] Migrate sendgrid modules

CO-1192 The mail are now correctly sent to all recipients
pull/185/head
Emanuel Cino 8 years ago
parent
commit
a759994dc8
  1. 1
      .travis.yml
  2. 2
      mail_sendgrid/README.rst
  3. 13
      mail_sendgrid/__init__.py
  4. 25
      mail_sendgrid/__manifest__.py
  5. 51
      mail_sendgrid/__openerp__.py
  6. 13
      mail_sendgrid/controllers/__init__.py
  7. 15
      mail_sendgrid/controllers/json_request.py
  8. 17
      mail_sendgrid/controllers/sendgrid_event_webhook.py
  9. 13
      mail_sendgrid/models/__init__.py
  10. 15
      mail_sendgrid/models/email_lang_template.py
  11. 15
      mail_sendgrid/models/email_template.py
  12. 15
      mail_sendgrid/models/email_tracking.py
  13. 33
      mail_sendgrid/models/mail_mail.py
  14. 2
      mail_sendgrid/models/mail_tracking_event.py
  15. 20
      mail_sendgrid/models/sendgrid_template.py
  16. 15
      mail_sendgrid/models/substitution.py
  17. 13
      mail_sendgrid/tests/__init__.py
  18. 6
      mail_sendgrid/tests/test_mail_sendgrid.py
  19. 4
      mail_sendgrid/views/sendgrid_template_view.xml
  20. 13
      mail_sendgrid/wizards/__init__.py
  21. 15
      mail_sendgrid/wizards/email_template_preview.py
  22. 17
      mail_sendgrid/wizards/mail_compose_message.py
  23. 13
      mail_sendgrid_mass_mailing/__init__.py
  24. 21
      mail_sendgrid_mass_mailing/__manifest__.py
  25. 47
      mail_sendgrid_mass_mailing/__openerp__.py
  26. 13
      mail_sendgrid_mass_mailing/models/__init__.py
  27. 15
      mail_sendgrid_mass_mailing/models/email_tracking.py
  28. 15
      mail_sendgrid_mass_mailing/models/mail_mail.py
  29. 21
      mail_sendgrid_mass_mailing/models/mass_mailing.py
  30. 13
      mail_sendgrid_mass_mailing/tests/__init__.py
  31. 2
      mail_sendgrid_mass_mailing/tests/test_mass_mailing.py
  32. 57
      mail_sendgrid_mass_mailing/views/mass_mailing_view.xml
  33. 13
      mail_sendgrid_mass_mailing/wizards/__init__.py
  34. 15
      mail_sendgrid_mass_mailing/wizards/mail_compose_message.py
  35. 15
      mail_sendgrid_mass_mailing/wizards/test_mailing.py

1
.travis.yml

@ -28,6 +28,7 @@ virtualenv:
system_site_packages: true
install:
- pip install sendgrid
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly

2
mail_sendgrid/README.rst

@ -75,7 +75,7 @@ From e-mails, use the "Send (SendGrid)" button to send the e-mail using Sendgrid
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/205/9.0
:target: https://runbot.odoo-community.org/runbot/205/10.0
Known issues / Roadmap
======================

13
mail_sendgrid/__init__.py

@ -1,13 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Roman Zoller
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2015-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
from . import wizards

25
mail_sendgrid/__manifest__.py

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'SendGrid',
'version': '10.0.1.0.0',
'category': 'Social Network',
'author': 'Compassion CH, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'website': 'http://www.compassion.ch',
'depends': ['mail_tracking'],
'data': [
'security/ir.model.access.csv',
'views/sendgrid_email_view.xml',
'views/sendgrid_template_view.xml',
'views/mail_compose_message_view.xml',
'views/email_template_view.xml',
],
'demo': [],
'installable': True,
'auto_install': False,
'external_dependencies': {
'python': ['sendgrid'],
},
}

51
mail_sendgrid/__openerp__.py

@ -1,51 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# ______ Releasing children from poverty _
# / ____/___ ____ ___ ____ ____ ___________(_)___ ____
# / / / __ \/ __ `__ \/ __ \/ __ `/ ___/ ___/ / __ \/ __ \
# / /___/ /_/ / / / / / / /_/ / /_/ (__ |__ ) / /_/ / / / /
# \____/\____/_/ /_/ /_/ .___/\__,_/____/____/_/\____/_/ /_/
# /_/
# in Jesus' name
#
# Copyright (C) 2015-2017 Compassion CH (http://www.compassion.ch)
# @author: Emanuel Cino, Roman Zoller
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'SendGrid',
'version': '9.0.1.0.0',
'category': 'Social Network',
'author': 'Compassion CH',
'website': 'http://www.compassion.ch',
'depends': ['mail_tracking'],
'data': [
'security/ir.model.access.csv',
'views/sendgrid_email_view.xml',
'views/sendgrid_template_view.xml',
'views/mail_compose_message_view.xml',
'views/email_template_view.xml',
],
'demo': [],
'installable': True,
'auto_install': False,
'external_dependencies': {
'python': ['sendgrid'],
},
}

13
mail_sendgrid/controllers/__init__.py

@ -1,13 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import json_request
from . import sendgrid_event_webhook

15
mail_sendgrid/controllers/json_request.py

@ -1,16 +1,9 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import simplejson
from openerp.http import JsonRequest, Root, Response
from odoo.http import JsonRequest, Root, Response
# Monkeypatch type of request rooter to use RESTJsonRequest
old_get_request = Root.get_request

17
mail_sendgrid/controllers/sendgrid_event_webhook.py

@ -1,17 +1,10 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from openerp import http
from openerp.addons.mail_tracking.controllers.main import \
from odoo import http
from odoo.addons.mail_tracking.controllers.main import \
MailTrackingController, _env_get
_logger = logging.getLogger(__name__)

13
mail_sendgrid/models/__init__.py

@ -1,13 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Roman Zoller
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import mail_mail
from . import substitution

15
mail_sendgrid/models/email_lang_template.py

@ -1,15 +1,8 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields
from odoo import models, fields
class LanguageTemplate(models.Model):

15
mail_sendgrid/models/email_template.py

@ -1,15 +1,8 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Roman Zoller
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api
from odoo import models, fields, api
class EmailTemplate(models.Model):

15
mail_sendgrid/models/email_tracking.py

@ -1,19 +1,12 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016-2017 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from datetime import datetime
from werkzeug.useragents import UserAgent
from openerp import models, fields, api
from odoo import models, fields, api
_logger = logging.getLogger(__name__)

33
mail_sendgrid/models/mail_mail.py

@ -1,16 +1,9 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015-2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Roman Zoller, Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __openerp__.py
#
##############################################################################
from openerp import models, fields, api, exceptions, tools, _
from openerp.tools.config import config
from openerp.tools.safe_eval import safe_eval
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api, exceptions, tools, _
from odoo.tools.config import config
from odoo.tools.safe_eval import safe_eval
import base64
import logging
@ -122,8 +115,7 @@ class OdooMail(models.Model):
one. """
api_key = config.get('sendgrid_api_key')
if not api_key:
raise exceptions.Warning(
'ConfigError',
raise exceptions.UserError(
_('Missing sendgrid_api_key in conf file'))
sg = SendGridAPIClient(apikey=api_key)
@ -195,15 +187,16 @@ class OdooMail(models.Model):
subject = self.subject and self.subject.encode(
"utf_8") or "(No subject)"
personalization.subject = subject
addresses = list()
addresses = set()
if not test_address:
if self.email_to and self.email_to not in addresses:
personalization.add_to(Email(self.email_to))
addresses.append(self.email_to)
if self.email_to:
addresses = set(self.email_to.split(','))
for address in addresses:
personalization.add_to(Email(address))
for recipient in self.recipient_ids:
if recipient.email not in addresses:
personalization.add_to(Email(recipient.email))
addresses.append(recipient.email)
addresses.add(recipient.email)
if self.email_cc and self.email_cc not in addresses:
personalization.add_cc(Email(self.email_cc))
else:

2
mail_sendgrid/models/mail_tracking_event.py

@ -2,7 +2,7 @@
# © 2017 Emanuel Cino - <ecino@compassion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, api
from odoo import models, api
class MailTrackingEvent(models.Model):

20
mail_sendgrid/models/sendgrid_template.py

@ -1,15 +1,8 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Roman Zoller
#
# The licence is in the file __openerp__.py
#
##############################################################################
from openerp import models, fields, api, exceptions, _
from openerp.tools.config import config
# -*- coding: utf-8 -*-
# Copyright 2015-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api, exceptions, _
from odoo.tools.config import config
import json
import re
@ -49,8 +42,7 @@ class SendgridTemplate(models.Model):
def update(self):
api_key = config.get('sendgrid_api_key')
if not api_key:
raise exceptions.Warning(
'ConfigError',
raise exceptions.UserError(
_('Missing sendgrid_api_key in conf file'))
sg = sendgrid.SendGridAPIClient(apikey=api_key)

15
mail_sendgrid/models/substitution.py

@ -1,15 +1,8 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Roman Zoller, Emanuel Cino
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2015-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields
from odoo import models, fields
class Substitution(models.Model):

13
mail_sendgrid/tests/__init__.py

@ -1,12 +1,5 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2017 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2015-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_mail_sendgrid

6
mail_sendgrid/tests/test_mail_sendgrid.py

@ -2,7 +2,7 @@
# © 2017 Emanuel Cino - <ecino@compassion.ch>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import mock
from openerp.tests.common import TransactionCase
from odoo.tests.common import TransactionCase
mock_base_send = 'openerp.addons.mail.models.mail_mail.MailMail.send'
mock_sendgrid_api_client = ('openerp.addons.mail_sendgrid.models.mail_mail'
@ -75,7 +75,7 @@ class TestMailSendgrid(TransactionCase):
self.request = FakeRequest(self.event)
def create_email(self, vals=None):
mail_vals = self.mail_wizard.render_message(self.recipient.ids)[
mail_vals = self.mail_wizard.get_mail_values(self.recipient.ids)[
self.recipient.id]
mail_vals['recipient_ids'] = [(6, 0, self.recipient.ids)]
if vals is not None:
@ -93,7 +93,7 @@ class TestMailSendgrid(TransactionCase):
def test_create_email(self):
""" Test that Sendgrid template is pushed in e-mail. """
self.mail_template.update_substitutions()
mail_values = self.mail_wizard.render_message(self.recipient.ids)[
mail_values = self.mail_wizard.get_mail_values(self.recipient.ids)[
self.recipient.id]
# Test Sendgrid HTML preview
self.assertEqual(

4
mail_sendgrid/views/sendgrid_template_view.xml

@ -49,13 +49,11 @@
<record model="ir.actions.server" id="update_sendgrid_templates">
<field name="name">Update Sendgrid Templates</field>
<field name="model_id" ref="model_sendgrid_template"/>
<field name="code">
self.update(cr, uid, context=context)
<field name="code">object.update()
action = {
'name': 'Sendgrid templates',
'type': 'ir.actions.act_window',
'res_model': 'sendgrid.template',
'view_type': 'form',
'view_mode': 'tree,form'
}
</field>

13
mail_sendgrid/wizards/__init__.py

@ -1,13 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2015-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import mail_compose_message
from . import email_template_preview

15
mail_sendgrid/wizards/email_template_preview.py

@ -1,15 +1,8 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2015-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, api
from odoo import models, api
class EmailTemplatePreview(models.TransientModel):

17
mail_sendgrid/wizards/mail_compose_message.py

@ -1,15 +1,8 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __openerp__.py
#
##############################################################################
from openerp import models, fields, api
# -*- coding: utf-8 -*-
# Copyright 2015-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
class EmailComposeMessage(models.TransientModel):

13
mail_sendgrid_mass_mailing/__init__.py

@ -1,13 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
from . import wizards

21
mail_sendgrid_mass_mailing/__manifest__.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Mass Mailing with SendGrid',
'version': '10.0.1.0.0',
'category': 'Social Network',
'author': 'Compassion CH, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'website': 'http://www.compassion.ch',
'depends': ['mail_sendgrid', 'mail_tracking_mass_mailing'],
'data': [
'views/mass_mailing_view.xml'
],
'demo': [],
'installable': True,
'auto_install': True,
'external_dependencies': {
'python': ['sendgrid'],
},
}

47
mail_sendgrid_mass_mailing/__openerp__.py

@ -1,47 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# ______ Releasing children from poverty _
# / ____/___ ____ ___ ____ ____ ___________(_)___ ____
# / / / __ \/ __ `__ \/ __ \/ __ `/ ___/ ___/ / __ \/ __ \
# / /___/ /_/ / / / / / / /_/ / /_/ (__ |__ ) / /_/ / / / /
# \____/\____/_/ /_/ /_/ .___/\__,_/____/____/_/\____/_/ /_/
# /_/
# in Jesus' name
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# @author: Emanuel Cino <ecino@compassion.ch>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Mass Mailing with SendGrid',
'version': '9.0.1.0.0',
'category': 'Social Network',
'author': 'Compassion CH',
'website': 'http://www.compassion.ch',
'depends': ['mail_sendgrid', 'mail_tracking_mass_mailing'],
'data': [
'views/mass_mailing_view.xml'
],
'demo': [],
'installable': True,
'auto_install': True,
'external_dependencies': {
'python': ['sendgrid'],
},
}

13
mail_sendgrid_mass_mailing/models/__init__.py

@ -1,13 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import mass_mailing
from . import mail_mail

15
mail_sendgrid_mass_mailing/models/email_tracking.py

@ -1,14 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __openerp__.py
#
##############################################################################
from openerp import models, fields, api
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
class MailTrackingEvent(models.Model):

15
mail_sendgrid_mass_mailing/models/mail_mail.py

@ -1,14 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __openerp__.py
#
##############################################################################
from openerp import models
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
import logging
_logger = logging.getLogger(__name__)

21
mail_sendgrid_mass_mailing/models/mass_mailing.py

@ -1,17 +1,10 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import api, models, fields, _
from openerp.exceptions import Warning as UserError
from openerp.tools.safe_eval import safe_eval
from odoo import api, models, fields, _
from odoo.exceptions import Warning as UserError
from odoo.tools.safe_eval import safe_eval
class MassMailing(models.Model):
@ -98,7 +91,7 @@ class MassMailing(models.Model):
self.ensure_one()
if self.email_template_id:
# use E-mail Template
res_ids = self.get_recipients(self)
res_ids = self.get_recipients()
if not res_ids:
raise UserError(_('Please select recipients.'))
template = self.email_template_id

13
mail_sendgrid_mass_mailing/tests/__init__.py

@ -1,12 +1,5 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2017 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_mass_mailing

2
mail_sendgrid_mass_mailing/tests/test_mass_mailing.py

@ -2,7 +2,7 @@
# © 2017 Emanuel Cino - <ecino@compassion.ch>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import mock
from openerp.tests.common import TransactionCase
from odoo.tests.common import TransactionCase
mock_sendgrid_api_client = ('openerp.addons.mail_sendgrid.models.mail_mail'
'.SendGridAPIClient')

57
mail_sendgrid_mass_mailing/views/mass_mailing_view.xml

@ -1,31 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Form view -->
<record id="view_email_template_sendgrid_form" model="ir.ui.view">
<field name="name">mass.mailing.sendgrid.form</field>
<field name="model">mail.mass_mailing</field>
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='mailing_model']/.." position="after">
<field name="email_template_id" domain="[('model', '=', mailing_model), ('sendgrid_template_ids', '!=', False)]"/>
<field name="lang" attrs="{'invisible': [('email_template_id', '=', False)]}"/>
</xpath>
<xpath expr="//notebook/page[1]" position="after">
<page string="Sendgrid Preview" attrs="{'invisible': [('email_template_id', '=', False)]}">
<field name="html_copy" invisible="1"/>
<field name="body_sendgrid" widget="html"/>
</page>
</xpath>
<xpath expr="//notebook/page/group[1]">
<group string="Sendgrid Unsubscribe">
<field name="enable_unsubscribe"/>
<field name="unsubscribe_text" attrs="{'invisible': [('enable_unsubscribe', '=', False)]}"/>
<field name="unsubscribe_tag" attrs="{'invisible': [('enable_unsubscribe', '=', False)]}"/>
</group>
</xpath>
</field>
</record>
</data>
</openerp>
<odoo>
<!-- Form view -->
<record id="view_email_template_sendgrid_form" model="ir.ui.view">
<field name="name">mass.mailing.sendgrid.form</field>
<field name="model">mail.mass_mailing</field>
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='mailing_model']/.." position="after">
<field name="email_template_id" domain="[('model', '=', mailing_model), ('sendgrid_template_ids', '!=', False)]"/>
<field name="lang" attrs="{'invisible': [('email_template_id', '=', False)]}"/>
</xpath>
<xpath expr="//notebook/page[1]" position="after">
<page string="Sendgrid Preview" attrs="{'invisible': [('email_template_id', '=', False)]}">
<field name="html_copy" invisible="1"/>
<field name="body_sendgrid" widget="html"/>
</page>
</xpath>
<xpath expr="//notebook/page/group[1]">
<group string="Sendgrid Unsubscribe">
<field name="enable_unsubscribe"/>
<field name="unsubscribe_text" attrs="{'invisible': [('enable_unsubscribe', '=', False)]}"/>
<field name="unsubscribe_tag" attrs="{'invisible': [('enable_unsubscribe', '=', False)]}"/>
</group>
</xpath>
</field>
</record>
</odoo>

13
mail_sendgrid_mass_mailing/wizards/__init__.py

@ -1,13 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import mail_compose_message
from . import test_mailing

15
mail_sendgrid_mass_mailing/wizards/mail_compose_message.py

@ -1,15 +1,8 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, api
from odoo import models, api
class EmailComposeMessage(models.TransientModel):

15
mail_sendgrid_mass_mailing/wizards/test_mailing.py

@ -1,15 +1,8 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __openerp__.py
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, api, tools
from odoo import models, api, tools
class TestMassMailing(models.TransientModel):

Loading…
Cancel
Save