Browse Source

[NEW][8.0] portal_welcome_email_template: Changes suggested by OCA

pull/42/head
Sergio Incaser 8 years ago
parent
commit
5ba6653be3
  1. 2
      portal_welcome_email_template/README.rst
  2. 3
      portal_welcome_email_template/__openerp__.py
  3. 39
      portal_welcome_email_template/wizards/portal_wizard.py

2
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
=====

3
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/",

39
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)
Loading…
Cancel
Save