Browse Source

[NEW][8.0] portal_welcome_email_template: Customize portal access email message with a email template

pull/42/head
Sergio Incaser 8 years ago
parent
commit
8dfff3a64d
  1. 72
      portal_welcome_email_template/README.rst
  2. 6
      portal_welcome_email_template/__init__.py
  3. 23
      portal_welcome_email_template/__openerp__.py
  4. 41
      portal_welcome_email_template/data/email_template_data.xml
  5. 86
      portal_welcome_email_template/i18n/es.po
  6. BIN
      portal_welcome_email_template/static/description/icon.png
  7. 6
      portal_welcome_email_template/wizards/__init__.py
  8. 52
      portal_welcome_email_template/wizards/portal_wizard.py

72
portal_welcome_email_template/README.rst

@ -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 email sent is sent to queue.
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.

6
portal_welcome_email_template/__init__.py

@ -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

23
portal_welcome_email_template/__openerp__.py

@ -0,0 +1,23 @@
# -*- 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": "Use an email template for send portal 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",
],
}

41
portal_welcome_email_template/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}&lt;${object.company_id.email}&gt;</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},&nbsp;</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>&nbsp;
</div>
<div>
Portal: ${ctx['portal_url']}&nbsp;
</div>
<div>
Database: ${ctx['db']}&nbsp;
</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>

86
portal_welcome_email_template/i18n/es.po

@ -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},&nbsp;</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>&nbsp;\n"
" </div>\n"
" <div>\n"
" Portal: ${ctx['portal_url']}&nbsp;\n"
" </div>\n"
" <div>\n"
" Database: ${ctx['db']}&nbsp;\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},&nbsp;</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>&nbsp;\n"
" </div>\n"
" <div>\n"
" Portal: ${ctx['portal_url']}&nbsp;\n"
" </div>\n"
" <div>\n"
" Base de datos: ${ctx['db']}&nbsp;\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}"

BIN
portal_welcome_email_template/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

6
portal_welcome_email_template/wizards/__init__.py

@ -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

52
portal_welcome_email_template/wizards/portal_wizard.py

@ -0,0 +1,52 @@
# -*- 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
from openerp import exceptions
from openerp.tools.translate import _
class WizardUser(models.TransientModel):
"""
A model to configure users in the portal wizard.
"""
_inherit = 'portal.wizard.user'
@api.model
def _send_email(self, wizard_user):
""" send notification email to a new portal user
@param wizard_user: browse record of model portal.wizard.user
@return: the id of the created mail.mail record
"""
this_context = self._context
this_user = self.env['res.users'].sudo().browse(self._uid)
if not this_user.email:
raise exceptions.Warning(
_('Email Required'),
_('You must have an email address in your User Preferences to '
'send emails.'))
# determine subject and body in the portal user's language
user = self.sudo()._retrieve_user(wizard_user)
context = dict(this_context or {}, lang=user.lang)
ctx_portal_url = dict(context, signup_force_type_in_url='')
portal_url = user.partner_id.with_context(
ctx_portal_url)._get_signup_url_for_action()[user.partner_id.id]
user.partner_id.with_context(context).signup_prepare()
template = self.env.ref(
'portal_welcome_email_template.portal_welcome_email')
ctx = this_context.copy()
ctx.update({
'login': user.login,
'portal_url': portal_url,
'db': self._cr.dbname,
'portal': wizard_user.wizard_id.portal_id.name,
'signup_url': user.signup_url,
'welcome_message': wizard_user.wizard_id.welcome_message or "",
})
result = template.with_context(ctx).generate_email_batch(
template.id, [user.id])[user.id]
return self.env['mail.mail'].with_context(this_context).create(result)
Loading…
Cancel
Save