diff --git a/portal_welcome_email_template/README.rst b/portal_welcome_email_template/README.rst
new file mode 100644
index 000000000..0e57bb832
--- /dev/null
+++ b/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 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
+
You have been given access to ${object.company_id.name}'s ${ctx['portal']}.
+Your login account data is:
++++ Username: ${ctx['login']} +++ Portal: ${ctx['portal_url']} +++ Database: ${ctx['db']} ++
${ctx['welcome_message']}
++-- +Automatic Email. +${object.company_id.name or ''} +]]> + + + + diff --git a/portal_welcome_email_template/i18n/es.po b/portal_welcome_email_template/i18n/es.po new file mode 100644 index 000000000..c24f7e76f --- /dev/null +++ b/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
Dear ${object.name},
\n" +"You have been given access to ${object.company_id.name}'s " +"${ctx['portal']}.
\n" +"Your login account data is:
\n" +"\n" +"\n" +"\n" +" Username: ${ctx['login']} \n" +"\n" +"\n" +" Portal: ${ctx['portal_url']} \n" +"\n" +"\n" +" Database: ${ctx['db']} \n" +"\n" +"
${ctx['welcome_message']}
\n" +"\n" +"--\n" +"Automatic Email.\n" +"${object.company_id.name or ''}\n" +"\n" +" " +msgstr "" +" \n" +" \n" +"
Estimado ${object.name},
\n" +"Se le ha dado acceso al ${ctx['portal']} de ${object.company_id.name}." +"p>\n" +"
Las credenciales de su cuenta son:
\n" +"\n" +"\n" +"\n" +" Usuario: ${ctx['login']} \n" +"\n" +"\n" +" Portal: ${ctx['portal_url']} \n" +"\n" +"\n" +" Base de datos: ${ctx['db']} \n" +"\n" +"
${ctx['welcome_message']}
\n" +"\n" +"--\n" +"Email automático .\n" +"${object.company_id.name or ''}\n" +"\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}" diff --git a/portal_welcome_email_template/static/description/icon.png b/portal_welcome_email_template/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/portal_welcome_email_template/static/description/icon.png differ diff --git a/portal_welcome_email_template/tests/__init__.py b/portal_welcome_email_template/tests/__init__.py new file mode 100644 index 000000000..e0deade8a --- /dev/null +++ b/portal_welcome_email_template/tests/__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 test_portal_welcome_email_template diff --git a/portal_welcome_email_template/tests/test_portal_welcome_email_template.py b/portal_welcome_email_template/tests/test_portal_welcome_email_template.py new file mode 100644 index 000000000..90ea93fa8 --- /dev/null +++ b/portal_welcome_email_template/tests/test_portal_welcome_email_template.py @@ -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) diff --git a/portal_welcome_email_template/wizards/__init__.py b/portal_welcome_email_template/wizards/__init__.py new file mode 100644 index 000000000..9601b867a --- /dev/null +++ b/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 diff --git a/portal_welcome_email_template/wizards/portal_wizard.py b/portal_welcome_email_template/wizards/portal_wizard.py new file mode 100644 index 000000000..16d54b68e --- /dev/null +++ b/portal_welcome_email_template/wizards/portal_wizard.py @@ -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)