diff --git a/.travis.yml b/.travis.yml
index c3bcf99d..c8f9fedb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,6 +15,7 @@ addons:
env:
global:
- VERSION="10.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0"
+ - PHANTOMJS_VERSION="2.1.2" WEBSITE_REPO="1"
- TRANSIFEX_USER='transbot@odoo-community.org'
- secure: "GRXFURohRzzBbzRovVHd+cObj1yBe9x9bddKqUo7jEGPo+MYHKfGo1M7disTDq6HPLgCwacbhWRsMavGORB3AEkoNewP7q31MKGGPiS8Com9wMmYUtDPs4ZiuUlakJjvfsmGlpwTWUe1Xv1YSZweXVGIESAn0SwhzKHrSKiTcSFAapTwdZXt0lKIsDcra/xOesJ8p9QjY4mzsgyeLrLUSq/Gpt/icAJeoktJ2c4Z6sMV4ozbaRgMFSMCxXKXQTNtLgFICfiJZ2PAw3BQTYo6iX0sdX3RekvaWVBiFr1iblrFjZleoZ9CnkOEKq0JL8EXHMeX7UBvkSJvQV4M3DPd5GdHA0docKDwgdJKUSP9oxBJ6ElYxG5/bbwOxWfY0x6mh/iJdSuNyrfaUqzaCfhQsckuEw6IgqcMGWLPoO5FSovzAtC+u0+GIqphyFsA25lku9B76eZB8KuqWEUJGQZswIOYUKc0i1A2S/ej6MjCYW0BrazhN5laP/6nu7RHmYs0sIrIaxeJJZG0AaVKWAXmTbcDplF07wzwQau4nk922pH5Bxmt2hB1BOzeOqCGnE3wTOAuacuDIfyJaIpTmNMALWeWk/EkMghDZXRRCEueZO5QR2LdcxJk86x5ANj6sxKVo+nkl+x93ZBsehqELn4rTHwjAaA+Ck3vWRkzfV8nJ3A="
matrix:
diff --git a/website_mass_mailing_name/README.rst b/website_mass_mailing_name/README.rst
new file mode 100644
index 00000000..7c573cb7
--- /dev/null
+++ b/website_mass_mailing_name/README.rst
@@ -0,0 +1,60 @@
+.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
+ :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ :alt: License: LGPL-3
+
+===========================================
+Mass Mailing Subscription Snippet With Name
+===========================================
+
+This module extends the functionality of mass mailings to support asking for
+the contact name directly in the subscription snippet.
+
+If you want to get partners created automatically and linked to the contacts,
+you can additionally install the `mass_mailing_partner
+`_ module.
+
+Usage
+=====
+
+To use this module, you need to:
+
+#. Go to any website page.
+#. Insert any structure block.
+#. Insert the *Newsletter* block as you would usually, inside a structure one.
+#. Choose the newsletter of your liking.
+#. Press *Save*.
+
+.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
+ :alt: Try me on Runbot
+ :target: https://runbot.odoo-community.org/runbot/186/10.0
+
+Bug Tracker
+===========
+
+Bugs are tracked on `GitHub Issues
+`_. In case of trouble, please
+check there if your issue has already been reported. If you spotted it first,
+help us smashing it by providing a detailed and welcomed feedback.
+
+Credits
+=======
+
+Contributors
+------------
+
+* Jairo Llopis
+
+Maintainer
+----------
+
+.. image:: https://odoo-community.org/logo.png
+ :alt: Odoo Community Association
+ :target: https://odoo-community.org
+
+This module is maintained by the OCA.
+
+OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
+To contribute to this module, please visit https://odoo-community.org.
diff --git a/website_mass_mailing_name/__init__.py b/website_mass_mailing_name/__init__.py
new file mode 100644
index 00000000..16545e96
--- /dev/null
+++ b/website_mass_mailing_name/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
+
+from . import controllers
diff --git a/website_mass_mailing_name/__manifest__.py b/website_mass_mailing_name/__manifest__.py
new file mode 100644
index 00000000..019fc542
--- /dev/null
+++ b/website_mass_mailing_name/__manifest__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+# Copyright 2016-2017 Jairo Llopis
+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
+{
+ "name": "Mass Mailing Subscription Snippet With Name",
+ "summary": "Ask for name when subscribing, and create and/or link partner",
+ "version": "10.0.1.0.0",
+ "category": "Website",
+ "website": "https://tecnativa.com/",
+ "author": "Tecnativa, Odoo Community Association (OCA)",
+ "license": "LGPL-3",
+ "application": False,
+ "installable": True,
+ "depends": [
+ "website_mass_mailing",
+ ],
+ "demo": [
+ "demo/assets.xml",
+ ],
+ "data": [
+ "templates/assets.xml",
+ "templates/snippets.xml",
+ ],
+}
diff --git a/website_mass_mailing_name/controllers/__init__.py b/website_mass_mailing_name/controllers/__init__.py
new file mode 100644
index 00000000..c02fd56e
--- /dev/null
+++ b/website_mass_mailing_name/controllers/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
+
+from . import main
diff --git a/website_mass_mailing_name/controllers/main.py b/website_mass_mailing_name/controllers/main.py
new file mode 100644
index 00000000..cb50267c
--- /dev/null
+++ b/website_mass_mailing_name/controllers/main.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+# Copyright 2016-2017 Jairo Llopis
+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
+
+from odoo.addons.website_mass_mailing.controllers import main
+from odoo.http import request, route
+
+
+class MassMailController(main.MassMailController):
+ @route()
+ def is_subscriber(self, *args, **kwargs):
+ """Get user name too."""
+ result = super(MassMailController, self).is_subscriber(*args, **kwargs)
+ if request.website.user_id != request.env.user:
+ name = request.env.user.name
+ else:
+ name = request.session.get("mass_mailing_name", "")
+ return dict(result, name=name)
+
+ @route()
+ def subscribe(self, list_id, email, **post):
+ """Store email with name in session."""
+ result = super(MassMailController, self).subscribe(
+ list_id, email, **post)
+ name, email = request.env['mail.mass_mailing.contact'].sudo() \
+ .get_name_email(email)
+ request.session["mass_mailing_name"] = name if name != email else ""
+ return result
diff --git a/website_mass_mailing_name/demo/assets.xml b/website_mass_mailing_name/demo/assets.xml
new file mode 100644
index 00000000..b569efc6
--- /dev/null
+++ b/website_mass_mailing_name/demo/assets.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/website_mass_mailing_name/i18n/de.po b/website_mass_mailing_name/i18n/de.po
new file mode 100644
index 00000000..9319d0b6
--- /dev/null
+++ b/website_mass_mailing_name/i18n/de.po
@@ -0,0 +1,24 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * website_mass_mailing_name
+#
+# Translators:
+# Rudolf Schnapka , 2017
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-04-30 10:22+0000\n"
+"PO-Revision-Date: 2017-04-30 10:22+0000\n"
+"Last-Translator: Rudolf Schnapka , 2017\n"
+"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: de\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: website_mass_mailing_name
+#: view:website:website.snippets
+msgid "your name..."
+msgstr "Ihr Name..."
diff --git a/website_mass_mailing_name/i18n/es.po b/website_mass_mailing_name/i18n/es.po
new file mode 100644
index 00000000..414d9440
--- /dev/null
+++ b/website_mass_mailing_name/i18n/es.po
@@ -0,0 +1,23 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * website_mass_mailing_name
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-05-24 15:03+0000\n"
+"PO-Revision-Date: 2016-05-24 17:04+0200\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+"Language: es\n"
+"X-Generator: Poedit 1.8.7.1\n"
+
+#. module: website_mass_mailing_name
+#: view:website:website.snippets
+msgid "your name..."
+msgstr "su nombre..."
diff --git a/website_mass_mailing_name/i18n/fr.po b/website_mass_mailing_name/i18n/fr.po
new file mode 100644
index 00000000..b5d843b3
--- /dev/null
+++ b/website_mass_mailing_name/i18n/fr.po
@@ -0,0 +1,24 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * website_mass_mailing_name
+#
+# Translators:
+# Christophe CHAUVET , 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-06-30 01:08+0000\n"
+"PO-Revision-Date: 2016-06-30 01:08+0000\n"
+"Last-Translator: Christophe CHAUVET , 2016\n"
+"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: fr\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#. module: website_mass_mailing_name
+#: view:website:website.snippets
+msgid "your name..."
+msgstr "votre nom..."
diff --git a/website_mass_mailing_name/i18n/sl.po b/website_mass_mailing_name/i18n/sl.po
new file mode 100644
index 00000000..6a319b33
--- /dev/null
+++ b/website_mass_mailing_name/i18n/sl.po
@@ -0,0 +1,24 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * website_mass_mailing_name
+#
+# Translators:
+# Matjaž Mozetič , 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-06-30 01:08+0000\n"
+"PO-Revision-Date: 2016-06-30 01:08+0000\n"
+"Last-Translator: Matjaž Mozetič , 2016\n"
+"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: sl\n"
+"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
+
+#. module: website_mass_mailing_name
+#: view:website:website.snippets
+msgid "your name..."
+msgstr "vaše ime..."
diff --git a/website_mass_mailing_name/static/description/icon.png b/website_mass_mailing_name/static/description/icon.png
new file mode 100644
index 00000000..b18b21a1
Binary files /dev/null and b/website_mass_mailing_name/static/description/icon.png differ
diff --git a/website_mass_mailing_name/static/src/css/website_mass_mailing_name.sass b/website_mass_mailing_name/static/src/css/website_mass_mailing_name.sass
new file mode 100644
index 00000000..094153aa
--- /dev/null
+++ b/website_mass_mailing_name/static/src/css/website_mass_mailing_name.sass
@@ -0,0 +1,10 @@
+/*! Copyright 2016-2017 Jairo Llopis
+ License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
+
+.js_subscribe
+ .form-control
+ width: 50%
+
+ &[data-subscribe="on"]
+ .js_subscribe_name:not([disabled])
+ display: none
diff --git a/website_mass_mailing_name/static/src/js/editor_tour.js b/website_mass_mailing_name/static/src/js/editor_tour.js
new file mode 100644
index 00000000..b6fe1c95
--- /dev/null
+++ b/website_mass_mailing_name/static/src/js/editor_tour.js
@@ -0,0 +1,50 @@
+/* Copyright 2016-2017 Jairo Llopis
+ * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
+odoo.define("website_mass_mailing_name.editor_tour", function (require) {
+ "use strict";
+ var base = require("web_editor.base");
+ var tour = require("web_tour.tour");
+
+ tour.register(
+ "mass_mailing_name_editor",
+ {
+ test: true,
+ wait_for: base.ready(),
+ },
+ [
+ {
+ content: "Edit the homepage",
+ trigger: ".o_menu_systray a[data-action=edit]",
+ },
+ {
+ content: "Drag and drop a text snippet",
+ trigger: ".oe_snippet[name='Text Block'] .oe_snippet_thumbnail",
+ run: "drag_and_drop #wrap",
+ },
+ {
+ content: "Drag and drop a newsletter snippet",
+ trigger: ".oe_snippet[name='Newsletter'] .oe_snippet_thumbnail",
+ run: "drag_and_drop #wrap .s_text_block",
+ },
+ {
+ content: "Let the default mailing list",
+ trigger: ".modal-dialog button:contains('Continue')",
+ },
+ {
+ content: "Save changes",
+ extra_trigger: "body:not(:has(.modal:visible))",
+ trigger: "#web_editor-top-edit button[data-action=save]",
+ },
+ {
+ content: "Subscribe Administrator",
+ extra_trigger: "body:not(:has(#web_editor-top-edit))",
+ trigger: ".js_subscribe_btn",
+ },
+ {
+ content: "Open user menu",
+ extra_trigger: ".js_subscribe .alert-success",
+ trigger: "#top_menu span:contains('Administrator')",
+ },
+ ]
+ );
+});
diff --git a/website_mass_mailing_name/static/src/js/public_tour.js b/website_mass_mailing_name/static/src/js/public_tour.js
new file mode 100644
index 00000000..6236747b
--- /dev/null
+++ b/website_mass_mailing_name/static/src/js/public_tour.js
@@ -0,0 +1,77 @@
+/* Copyright 2016-2017 Jairo Llopis
+ * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
+odoo.define("website_mass_mailing_name.public_tour", function (require) {
+ "use strict";
+ var base = require("web_editor.base");
+ var tour = require("web_tour.tour");
+
+ tour.register(
+ "mass_mailing_name_public",
+ {
+ test: true,
+ wait_for: base.ready(),
+ },
+ [
+ {
+ content: "Try to subscribe without data",
+ trigger: ".js_subscribe_btn",
+ },
+ {
+ content: "Enter a name",
+ extra_trigger: ".js_subscribe.has-error",
+ trigger: ".js_subscribe_name",
+ run: "text Visitor",
+ },
+ {
+ content: "Try to subscribe without email",
+ trigger: ".js_subscribe_btn",
+ },
+ {
+ content: "Remove the name",
+ extra_trigger: ".js_subscribe.has-error",
+ trigger: ".js_subscribe_name",
+ run: function () {
+ $(".js_subscribe_name").val("");
+ },
+ },
+ {
+ content: "Enter an email",
+ trigger: ".js_subscribe_email",
+ run: "text example@example.com",
+ },
+ {
+ content: "Try to subscribe without name",
+ trigger: ".js_subscribe_btn",
+ },
+ {
+ content: "Enter the name again",
+ extra_trigger: ".js_subscribe.has-error",
+ trigger: ".js_subscribe_name",
+ run: "text Visitor",
+ },
+ {
+ content: "Enter a wrong email",
+ trigger: ".js_subscribe_email",
+ run: "text bad email",
+ },
+ {
+ content: "Try to subscribe with a bad email",
+ trigger: ".js_subscribe_btn",
+ },
+ {
+ content: "Enter the good email",
+ extra_trigger: ".js_subscribe.has-error",
+ trigger: ".js_subscribe_email",
+ run: "text example@example.com",
+ },
+ {
+ content: "Try to subscribe with good information",
+ trigger: ".js_subscribe_btn",
+ },
+ {
+ content: "Subscription successful",
+ trigger: ".js_subscribe:not(.has-error) .alert-success",
+ },
+ ]
+ );
+});
diff --git a/website_mass_mailing_name/static/src/js/website_mass_mailing_name.js b/website_mass_mailing_name/static/src/js/website_mass_mailing_name.js
new file mode 100644
index 00000000..922faf96
--- /dev/null
+++ b/website_mass_mailing_name/static/src/js/website_mass_mailing_name.js
@@ -0,0 +1,59 @@
+/* Copyright 2016-2017 Jairo Llopis
+ * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
+
+odoo.define("website_mass_mailing_name.subscribe", function (require) {
+ "use strict";
+ require("mass_mailing.website_integration");
+ var animation = require("web_editor.snippets.animation");
+
+ animation.registry.subscribe.include({
+ start: function(editable_mode) {
+ this.$email = this.$target.find(".js_subscribe_email");
+ this.$name = this.$target.find(".js_subscribe_name");
+ // Thanks upstream for your @$?!! inheritance-ready code.
+ // Injecting ajax events to modify behavior of snippet.
+ if (this.$name) {
+ $(document).ajaxSend($.proxy(this.on_ajax_send, this));
+ }
+ return this._super(editable_mode);
+ },
+
+ on_click: function() {
+ var email_error = !this.$email.val().match(/.+@.+/),
+ name_error = this.$name.length && !this.$name.val(),
+ values = {
+ "list_id": this.$target.data('list-id'),
+ "email": this.$email.val(),
+ };
+ // Stop on error
+ if (email_error || name_error) {
+ this.$target.addClass("has-error")
+ return false;
+ }
+ return this._super.apply(this, arguments);
+ },
+
+ on_ajax_send: function(event, jqXHR, ajaxOptions) {
+ // Add handlers on correct requests
+ if (ajaxOptions.url == "/website_mass_mailing/is_subscriber") {
+ jqXHR.done($.proxy(this.on_start, this));
+ } else if (ajaxOptions.url == "/website_mass_mailing/subscribe") {
+ var data = JSON.parse(ajaxOptions.data);
+ data.params.email = _.str.sprintf(
+ "%s <%s>",
+ this.$name.val(),
+ data.params.email
+ );
+ ajaxOptions.data = JSON.stringify(data);
+ }
+ },
+
+ on_start: function(data) {
+ this.$name.val(data.result.name)
+ .attr(
+ "disabled",
+ Boolean(data.result.is_subscriber && data.result.name.length)
+ );
+ },
+ });
+});
diff --git a/website_mass_mailing_name/templates/assets.xml b/website_mass_mailing_name/templates/assets.xml
new file mode 100644
index 00000000..52c9f08d
--- /dev/null
+++ b/website_mass_mailing_name/templates/assets.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/website_mass_mailing_name/templates/snippets.xml b/website_mass_mailing_name/templates/snippets.xml
new file mode 100644
index 00000000..7b1580ef
--- /dev/null
+++ b/website_mass_mailing_name/templates/snippets.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/website_mass_mailing_name/tests/__init__.py b/website_mass_mailing_name/tests/__init__.py
new file mode 100644
index 00000000..211f990a
--- /dev/null
+++ b/website_mass_mailing_name/tests/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
+
+from . import test_ui
diff --git a/website_mass_mailing_name/tests/test_ui.py b/website_mass_mailing_name/tests/test_ui.py
new file mode 100644
index 00000000..f0ad2105
--- /dev/null
+++ b/website_mass_mailing_name/tests/test_ui.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Copyright 2016-2017 Jairo Llopis
+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
+
+from odoo.http import root
+from odoo.tests.common import HttpCase
+
+
+class UICase(HttpCase):
+ def test_ui(self):
+ """Test snippet behavior."""
+ tour = "odoo.__DEBUG__.services['web_tour.tour'].%s"
+ # Admin edits home page and adds subscription snippet
+ self.phantom_js(
+ "/",
+ tour % "run('mass_mailing_name_editor')",
+ tour % "tours.mass_mailing_name_editor.ready",
+ login="admin")
+ # Forced log out
+ root.session_store.delete(self.session)
+ # Public user uses subscription snippet
+ self.phantom_js(
+ "/",
+ tour % "run('mass_mailing_name_public')",
+ tour % "tours.mass_mailing_name_public.ready")