Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0][ADD][website_snippet_mass_mailing_partner] Snippet + name #201

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
server-tools
crm
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gurneyalex Runbot fails because it lacks this repo, could you add it please?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added it.

server-tools
63 changes: 63 additions & 0 deletions website_snippet_mass_mailing_partner/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

===========================================
Mass Mailing Subscription Snippet With Name
===========================================

This module extends the functionality of ``mass_mailing_partner`` to support
asking for the contact name directly in the subscription snippet and allow you
to get partners created automatically and linked to the contacts.

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/8.0

Known issues / Roadmap
======================

* If you use Firefox, you could hit https://github.com/odoo/odoo/issues/7722.
Just use Chromium to work with this snippet until you update to Odoo 9.0.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/website/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 <jairo.llopis@tecnativa.com>

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.
5 changes: 5 additions & 0 deletions website_snippet_mass_mailing_partner/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import controllers
21 changes: 21 additions & 0 deletions website_snippet_mass_mailing_partner/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Mass Mailing Subscription Snippet With Name",
"summary": "Ask for name when subscribing, and create and/or link partner",
"version": "8.0.1.0.0",
"category": "Website",
"website": "https://tecnativa.com/",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"mass_mailing_partner",
],
"data": [
"views/assets.xml",
"views/snippets.xml",
],
}
5 changes: 5 additions & 0 deletions website_snippet_mass_mailing_partner/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import main
20 changes: 20 additions & 0 deletions website_snippet_mass_mailing_partner/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp.addons.mass_mailing.controllers.main import MassMailController
from openerp.http import request, route


class MassMailingPartner(MassMailController):
@route()
def subscribe(self, list_id, email, **post):
"""Handle name if provided."""
Partner = request.env["res.partner"].sudo()
name = post.get("name")

# Update partner's name, to make it get updated in contact list later
Partner.search([("email", "=", email)], limit=1).write({"name": name})

return super(MassMailingPartner, self).subscribe(
list_id, email, **post)
23 changes: 23 additions & 0 deletions website_snippet_mass_mailing_partner/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_snippet_mass_mailing_partner
#
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_snippet_mass_mailing_partner
#: view:website:website.snippets
msgid "your name..."
msgstr "su nombre..."
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@charset "UTF-8"
/* © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

.js_subscribe
.form-control
width: 50%
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */

"use strict";
(function ($) {
openerp.website.snippet.animationRegistry.subscribe.include({
on_click: function() {
var self = this;
var $email = this.$target.find(".js_subscribe_email:visible");
var $name = this.$target.find(".js_subscribe_name:visible");

if (
($email.length && !$email.val().match(/.+@.+/)) ||
($name.length && !$name.val())
) {
this.$target.addClass('has-error');
return false;
}
this.$target.removeClass('has-error');

openerp.jsonRpc('/website_mass_mailing/subscribe', 'call', {
'list_id': this.$target.data('list-id'),
'email': $email.length ? $email.val() : false,
'name': $name.length && $name.val(),
}).then(function (subscribe) {
self.$target.children("input, span").addClass("hidden");
self.$target.find(".alert").removeClass("hidden");
self.$target.find('input.js_subscribe_email')
.attr("disabled", subscribe);
self.$target.attr("data-subscribe", subscribe ? 'on' : 'off');
});
},
});
})(jQuery);
19 changes: 19 additions & 0 deletions website_snippet_mass_mailing_partner/views/assets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<openerp>
<data>

<template id="assets_frontend"
inherit_id="mass_mailing.assets_frontend">
<xpath expr=".">
<link rel="stylesheet"
href="/website_snippet_mass_mailing_partner/static/src/css/website_snippet_mass_mailing_partner.css"/>
<script type="text/javascript"
src="/website_snippet_mass_mailing_partner/static/src/js/website_snippet_mass_mailing_partner.js"/>
</xpath>
</template>

</data>
</openerp>
20 changes: 20 additions & 0 deletions website_snippet_mass_mailing_partner/views/snippets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<openerp>
<data>

<template id="mailing_list_subscribe"
inherit_id="mass_mailing.mailing_list_subscribe">
<xpath expr="//input[@class='js_subscribe_email form-control']"
position="before">
<input
name="name"
class="js_subscribe_name form-control"
placeholder="your name..."/>
</xpath>
</template>

</data>
</openerp>