From 8dfff3a64d96be950db005c4a5d80bc9e7b4fcaf Mon Sep 17 00:00:00 2001
From: Sergio Incaser
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 00000000..c24f7e76 --- /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 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}
2eS*sE*o R$@pexaqr*meB)VhmIg@h{uzkk$9~qh#cHhw#>O%)b@+(| z^IQgqzuj~Sk(J;swEM-3TrJAPCq9k^^^`q{IItKBRXYe}e0Tdr=Huf7da3$l4 PdpwWDop%^}n;dD#K4s#DYA8SHZ z&1!riV4W4R7R#C))JH1~axJ)RYnM$$lIR%6fIVA@zV{XVyx}C+a-Dt8Y9M)^KU0+H zR4IUb2CJ{Hg>CuaXtD50jB(_Tcx=Z$^W Yu2u5kubqmwp%drJ6 z?Fo40g!Qd<-l=TQxqHEOuPX0;^z7iX?Ke^a%XT<13TA^5`4Xcw6D@Ur&VT&CUe0d} z1GjOVF1^L@>O)l@?bD~$wzgf(nxX1OGD8fEV?TdJcZc2KoUe|oP1#=$$7ee|xbY)A zDZq+cuTpc(fFdj^=!;{k03C69lMQ(|>uhRfRu%+!k& YOi-3|1QKB z z?n?eq1XP>p-IM$Z^C;2L3itnbJZAip*Zo0aw2bs8@(s^~*8T9go!%dHcAz2lM;`yp zD=7&xjFV$S&5uDaiScyD?B-i1ze`+CoRtz`Wn+Zls4&}MO{@N!ufrzjG$B79)Y2d3tBk&)TxUTw@ QS0TEL_?njX| @vq?Uz(nBFK5Pq7*xj#u*R&i|?7+6# z+|r_n#SW&LXhtheZdah{ZVoqwyT{D>MC3nkFF#N)xLi{p7J1jXlmVeb;cP5?e(=f# zuT7fv jSbjS781v?7{)-X3*?>tq?)Yd)~|1{BDS(pqC zC}~H#WXlkUW*H5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Rb zOr}WVFP--DsS`1WpN%~)t3R!arKF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4 z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_N hT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV* vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+Q P?#mo v zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB 0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/portal_welcome_email_template/wizards/__init__.py b/portal_welcome_email_template/wizards/__init__.py new file mode 100644 index 00000000..9601b867 --- /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 00000000..c9a3ab16 --- /dev/null +++ b/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) From 5ba6653be354d71ecb10385f9e0c252cbac26544 Mon Sep 17 00:00:00 2001 From: Sergio Incaser Date: Thu, 11 Feb 2016 10:13:17 +0100 Subject: [PATCH 2/4] [NEW][8.0] portal_welcome_email_template: Changes suggested by OCA --- portal_welcome_email_template/README.rst | 2 +- portal_welcome_email_template/__openerp__.py | 3 +- .../wizards/portal_wizard.py | 39 ++++++------------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/portal_welcome_email_template/README.rst b/portal_welcome_email_template/README.rst index 091183d5..0e57bb83 100644 --- a/portal_welcome_email_template/README.rst +++ b/portal_welcome_email_template/README.rst @@ -8,7 +8,7 @@ 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. +The sent email is enqueued instead of being directly processed. Usage ===== diff --git a/portal_welcome_email_template/__openerp__.py b/portal_welcome_email_template/__openerp__.py index deacd31d..796b6012 100644 --- a/portal_welcome_email_template/__openerp__.py +++ b/portal_welcome_email_template/__openerp__.py @@ -5,7 +5,8 @@ { "name": "Portal Welcome Email Template", - "summary": "Use an email template for send portal invitation", + "summary": "Adds an customizable email template for portal user " + "invitation", "version": "8.0.1.0.0", "category": "Tools", "website": "https://odoo-community.org/", diff --git a/portal_welcome_email_template/wizards/portal_wizard.py b/portal_welcome_email_template/wizards/portal_wizard.py index c9a3ab16..16d54b68 100644 --- a/portal_welcome_email_template/wizards/portal_wizard.py +++ b/portal_welcome_email_template/wizards/portal_wizard.py @@ -4,49 +4,32 @@ # 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='') + user = self._retrieve_user(wizard_user) 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() + 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 = this_context.copy() + + ctx = self.env.context.copy() ctx.update({ 'login': user.login, 'portal_url': portal_url, - 'db': self._cr.dbname, + '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 "", + '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) + return template.with_context(ctx).send_mail(user.id) From 4876c0e73b32046198bb5ec4b3c6374ea3ee0ef8 Mon Sep 17 00:00:00 2001 From: Sergio Incaser Date: Thu, 11 Feb 2016 12:40:53 +0100 Subject: [PATCH 3/4] [NEW][8.0] portal_welcome_email_template: Add test --- .../tests/__init__.py | 6 ++++ .../test_portal_welcome_email_template.py | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 portal_welcome_email_template/tests/__init__.py create mode 100644 portal_welcome_email_template/tests/test_portal_welcome_email_template.py diff --git a/portal_welcome_email_template/tests/__init__.py b/portal_welcome_email_template/tests/__init__.py new file mode 100644 index 00000000..e0deade8 --- /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 00000000..cbc00a6b --- /dev/null +++ b/portal_welcome_email_template/tests/test_portal_welcome_email_template.py @@ -0,0 +1,32 @@ +# -*- 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() + self.partner_obj = self.env['res.partner'] + self.partner = self.env.ref('base.res_partner_address_4') + + self.wiz_portal_access = self.env['portal.wizard'].create({ + 'user_ids': [(0, 0, { + 'partner_id': self.partner.id, + '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) From ecfe114eb5141d8dfbcd936c773f6afef6cb0bfc Mon Sep 17 00:00:00 2001 From: Sergio Incaser Date: Thu, 11 Feb 2016 13:43:50 +0100 Subject: [PATCH 4/4] [NEW][8.0] portal_welcome_email_template: fix test --- .../tests/test_portal_welcome_email_template.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 index cbc00a6b..90ea93fa 100644 --- a/portal_welcome_email_template/tests/test_portal_welcome_email_template.py +++ b/portal_welcome_email_template/tests/test_portal_welcome_email_template.py @@ -10,12 +10,16 @@ class TestWelcomeEmailTemplate(TransactionCase): def setUp(self): super(TestWelcomeEmailTemplate, self).setUp() - self.partner_obj = self.env['res.partner'] - self.partner = self.env.ref('base.res_partner_address_4') + 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, })], })