mirror of https://github.com/OCA/social.git
Merge pull request #42 from incaser/8.0-portal_welcome_email_template
[NEW][8.0] portal_welcome_email_templatepull/43/head
commit
fdbdf2329e
|
@ -0,0 +1,72 @@
|
|||
.. 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
|
||||
|
||||
=============================
|
||||
Portal Welcome Email Template
|
||||
=============================
|
||||
|
||||
This module extends the functionality of portal module to allow customize the
|
||||
email message sent to customer in email template section.
|
||||
The sent email is enqueued instead of being directly processed.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To modify the email sent go to *Settings > Email > Email Template* and search
|
||||
'Portal Welcome Email'. You can rewrite the template.
|
||||
Variables are stored into ctx, example: *ctx['portal_url']*
|
||||
|
||||
Variables list:
|
||||
|
||||
* ctx['login']
|
||||
* ctx['portal_url']
|
||||
* ctx['db']
|
||||
* ctx['portal']
|
||||
* ctx['signup_url']
|
||||
* ctx['welcome_message']
|
||||
|
||||
|
||||
.. 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/8.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/OCA/social/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
|
||||
<https://github.com/OCA/social/issues/new?body=module:%20
|
||||
portal_welcome_email_template%0Aversion:%20
|
||||
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Images
|
||||
------
|
||||
|
||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Carlos Dauden <carlos@incaser.es>
|
||||
* Sergio Teruel <sergio@incaser.es>
|
||||
|
||||
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.
|
|
@ -0,0 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# (c) 2015 Incaser Informatica S.L. - Sergio Teruel
|
||||
# (c) 2015 Incaser Informatica S.L. - Carlos Dauden
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from . import wizards
|
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# (c) 2015 Incaser Informatica S.L. - Sergio Teruel
|
||||
# (c) 2015 Incaser Informatica S.L. - Carlos Dauden
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
{
|
||||
"name": "Portal Welcome Email Template",
|
||||
"summary": "Adds an customizable email template for portal user "
|
||||
"invitation",
|
||||
"version": "8.0.1.0.0",
|
||||
"category": "Tools",
|
||||
"website": "https://odoo-community.org/",
|
||||
'author': 'Incaser Informatica S.L., '
|
||||
'Odoo Community Association (OCA)',
|
||||
"license": "AGPL-3",
|
||||
"application": False,
|
||||
"installable": True,
|
||||
"depends": [
|
||||
"portal",
|
||||
],
|
||||
"data": [
|
||||
"data/email_template_data.xml",
|
||||
],
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="portal_welcome_email" model="email.template">
|
||||
<field name="name">Portal Welcome Email</field>
|
||||
<field name="email_from">${object.company_id.name}<${object.company_id.email}></field>
|
||||
<field name="subject">Your account at ${object.company_id.name}</field>
|
||||
<field name="email_to">${object.email}</field>
|
||||
<field name="lang">${object.lang}</field>
|
||||
<field name="model_id" ref="base.model_res_users"/>
|
||||
<field name="auto_delete" eval="True"/>
|
||||
<field name="body_html">
|
||||
<![CDATA[
|
||||
<p>Dear ${object.name}, </p>
|
||||
<p>You have been given access to ${object.company_id.name}'s ${ctx['portal']}.</p>
|
||||
<p>Your login account data is:</p>
|
||||
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
|
||||
<div>
|
||||
Username: <strong>${ctx['login']}</strong>
|
||||
</div>
|
||||
<div>
|
||||
Portal: ${ctx['portal_url']}
|
||||
</div>
|
||||
<div>
|
||||
Database: ${ctx['db']}
|
||||
</div>
|
||||
</blockquote>
|
||||
<br/>
|
||||
You can set or change your password via the following url:<br/>
|
||||
${ctx['signup_url']}<br/>
|
||||
<p>${ctx['welcome_message']}</p>
|
||||
<pre>
|
||||
--
|
||||
Automatic Email.
|
||||
${object.company_id.name or ''}
|
||||
</pre>]]>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +1,86 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * portal_welcome_email_template
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-02-09 08:29+0000\n"
|
||||
"PO-Revision-Date: 2016-02-09 09:30+0100\n"
|
||||
"Last-Translator: Sergio Teruel <sergio@incaser.es>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: es_ES\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.5.4\n"
|
||||
|
||||
#. module: portal_welcome_email_template
|
||||
#: model:email.template,body_html:portal_welcome_email_template.portal_welcome_email
|
||||
msgid ""
|
||||
" \n"
|
||||
"<p>Dear ${object.name}, </p>\n"
|
||||
"<p>You have been given access to ${object.company_id.name}'s "
|
||||
"${ctx['portal']}.</p>\n"
|
||||
"<p>Your login account data is:</p>\n"
|
||||
"<blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\">\n"
|
||||
" <div>\n"
|
||||
" Username: <strong>${ctx['login']}</strong> \n"
|
||||
" </div>\n"
|
||||
" <div>\n"
|
||||
" Portal: ${ctx['portal_url']} \n"
|
||||
" </div>\n"
|
||||
" <div>\n"
|
||||
" Database: ${ctx['db']} \n"
|
||||
" </div>\n"
|
||||
"</blockquote>\n"
|
||||
"<br/>\n"
|
||||
"You can set or change your password via the following url:<br/>\n"
|
||||
"${ctx['signup_url']}<br/>\n"
|
||||
"<p>${ctx['welcome_message']}</p>\n"
|
||||
"<pre>\n"
|
||||
"--\n"
|
||||
"Automatic Email.\n"
|
||||
"${object.company_id.name or ''}\n"
|
||||
"</pre>\n"
|
||||
" "
|
||||
msgstr ""
|
||||
" \n"
|
||||
" \n"
|
||||
"<p>Estimado ${object.name}, </p>\n"
|
||||
"<p>Se le ha dado acceso al ${ctx['portal']} de ${object.company_id.name}.</"
|
||||
"p>\n"
|
||||
"<p>Las credenciales de su cuenta son:</p>\n"
|
||||
"<blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\">\n"
|
||||
" <div>\n"
|
||||
" Usuario: <strong>${ctx['login']}</strong> \n"
|
||||
" </div>\n"
|
||||
" <div>\n"
|
||||
" Portal: ${ctx['portal_url']} \n"
|
||||
" </div>\n"
|
||||
" <div>\n"
|
||||
" Base de datos: ${ctx['db']} \n"
|
||||
" </div>\n"
|
||||
"</blockquote>\n"
|
||||
"<br/>\n"
|
||||
"Usted puede establecer ocambiar su contraseña pinchando en el siguiente "
|
||||
"enlace:<br/>\n"
|
||||
"${ctx['signup_url']}<br/>\n"
|
||||
"<p>${ctx['welcome_message']}</p>\n"
|
||||
"<pre>\n"
|
||||
"--\n"
|
||||
"Email automático .\n"
|
||||
"${object.company_id.name or ''}\n"
|
||||
"</pre>\n"
|
||||
" "
|
||||
|
||||
#. module: portal_welcome_email_template
|
||||
#: model:ir.model,name:portal_welcome_email_template.model_portal_wizard_user
|
||||
msgid "Portal User Config"
|
||||
msgstr "Configuración del portal de usuario"
|
||||
|
||||
#. module: portal_welcome_email_template
|
||||
#: model:email.template,subject:portal_welcome_email_template.portal_welcome_email
|
||||
msgid "Your account at ${object.company_id.name}"
|
||||
msgstr "Su cuenta en ${object.company_id.name}"
|
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
|
@ -0,0 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# (c) 2015 Incaser Informatica S.L. - Sergio Teruel
|
||||
# (c) 2015 Incaser Informatica S.L. - Carlos Dauden
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from . import test_portal_welcome_email_template
|
|
@ -0,0 +1,36 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# (c) 2015 Incaser Informatica S.L. - Sergio Teruel
|
||||
# (c) 2015 Incaser Informatica S.L. - Carlos Dauden
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from openerp.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestWelcomeEmailTemplate(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestWelcomeEmailTemplate, self).setUp()
|
||||
partner_obj = self.env['res.partner']
|
||||
self.partner = partner_obj.create({
|
||||
'name': 'partner_test',
|
||||
'email': 'test@example.com',
|
||||
})
|
||||
|
||||
self.wiz_portal_access = self.env['portal.wizard'].create({
|
||||
'user_ids': [(0, 0, {
|
||||
'partner_id': self.partner.id,
|
||||
'email': self.partner.email,
|
||||
'in_portal': True,
|
||||
})],
|
||||
})
|
||||
|
||||
def test_send_mail(self):
|
||||
self.wiz_portal_access.user_ids.action_apply()
|
||||
portal_user = self.env['res.users'].search(
|
||||
[('partner_id', '=', self.partner.id)])
|
||||
self.assertTrue(portal_user)
|
||||
mail = self.env['mail.mail'].search([
|
||||
('model', '=', 'res.users'),
|
||||
('res_id', '=', portal_user.id)
|
||||
])
|
||||
self.assertTrue(mail)
|
|
@ -0,0 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# (c) 2015 Incaser Informatica S.L. - Sergio Teruel
|
||||
# (c) 2015 Incaser Informatica S.L. - Carlos Dauden
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from . import portal_wizard
|
|
@ -0,0 +1,35 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# (c) 2015 Incaser Informatica S.L. - Sergio Teruel
|
||||
# (c) 2015 Incaser Informatica S.L. - Carlos Dauden
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from openerp import models, api
|
||||
|
||||
|
||||
class WizardUser(models.TransientModel):
|
||||
_inherit = 'portal.wizard.user'
|
||||
|
||||
@api.model
|
||||
def _send_email(self, wizard_user):
|
||||
# determine subject and body in the portal user's language
|
||||
user = self._retrieve_user(wizard_user)
|
||||
portal_url = user.partner_id.with_context(
|
||||
lang=user.lang,
|
||||
signup_force_type_in_url=''
|
||||
)._get_signup_url_for_action()[user.partner_id.id]
|
||||
user.partner_id.with_context(
|
||||
lang=user.lang, signup_force_type_in_url='').signup_prepare()
|
||||
|
||||
template = self.env.ref(
|
||||
'portal_welcome_email_template.portal_welcome_email')
|
||||
|
||||
ctx = self.env.context.copy()
|
||||
ctx.update({
|
||||
'login': user.login,
|
||||
'portal_url': portal_url,
|
||||
'db': self.env.cr.dbname,
|
||||
'portal': wizard_user.wizard_id.portal_id.name,
|
||||
'signup_url': user.signup_url,
|
||||
'welcome_message': wizard_user.wizard_id.welcome_message or '',
|
||||
})
|
||||
return template.with_context(ctx).send_mail(user.id)
|
Loading…
Reference in New Issue