本文整理汇总了Python中trytond.pool.Pool.queue_mail方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.queue_mail方法的具体用法?Python Pool.queue_mail怎么用?Python Pool.queue_mail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.pool.Pool
的用法示例。
在下文中一共展示了Pool.queue_mail方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_mail
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import queue_mail [as 别名]
def send_mail(self, receivers=None):
"""Send mail when task created.
:param receivers: Receivers of email.
"""
EmailQueue = Pool().get("email.queue")
subject = "[#%s %s] - %s" % (self.id, self.parent.rec_name, self.rec_name)
if not receivers:
receivers = [p.email for p in self.participants if p.email]
if self.created_by.email in receivers:
receivers.remove(self.created_by.email)
if not receivers:
return
message = render_email(
from_email=CONFIG["smtp_from"],
to=", ".join(receivers),
subject=subject,
text_template="project/emails/project_text_content.jinja",
html_template="project/emails/project_html_content.jinja",
task=self,
updated_by=request.nereid_user.display_name,
)
# Send mail.
EmailQueue.queue_mail(CONFIG["smtp_from"], receivers, message.as_string())
示例2: send_magic_login_link
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import queue_mail [as 别名]
def send_magic_login_link(cls, email):
"""
Send a magic login email to the user
"""
EmailQueue = Pool().get("email.queue")
try:
nereid_user, = cls.search([("email", "=", email.lower()), ("company", "=", current_website.company.id)])
except ValueError:
# This email was not found so, let user know about this
message = "No user with email %s was found!" % email
current_app.logger.debug(message)
else:
message = "Please check your mail and follow the link"
email_message = render_email(
config.get("email", "from"),
email,
_("Magic Signin Link"),
text_template="emails/magic-login-text.jinja",
html_template="emails/magic-login-html.jinja",
nereid_user=nereid_user,
)
EmailQueue.queue_mail(config.get("email", "from"), email, email_message.as_string())
return cls.build_response(message, redirect(url_for("nereid.website.home")), 200)
示例3: send_gift_card_as_email
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import queue_mail [as 别名]
def send_gift_card_as_email(self):
"""
Send gift card as an attachment in the email
"""
EmailQueue = Pool().get('email.queue')
GiftCardReport = Pool().get('gift_card.gift_card', type='report')
ModelData = Pool().get('ir.model.data')
Group = Pool().get('res.group')
group_id = ModelData.get_id(
"gift_card", "gift_card_email_receivers"
)
bcc_emails = map(
lambda user: user.email,
filter(lambda user: user.email, Group(group_id).users)
)
if not self.recipient_email: # pragma: no cover
return
# Try to generate report twice
# This is needed as sometimes `unoconv` fails to convert report to pdf
for try_count in range(2):
try:
val = GiftCardReport.execute([self.id], {})
break
except: # pragma: no cover
if try_count == 0:
continue
else:
return
subject = self._get_subject_for_email()
html_template, text_template = self._get_email_templates()
sender = config.get('email', 'from')
email_gift_card = render_email(
sender, self.recipient_email,
subject,
html_template=html_template,
text_template=text_template,
attachments={"%s.%s" % (val[3], val[0]): val[1]},
card=self,
)
EmailQueue.queue_mail(
sender, [self.recipient_email] + bcc_emails,
email_gift_card.as_string()
)
self.is_email_sent = True
self.save()
示例4: send_reset_email
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import queue_mail [as 别名]
def send_reset_email(self):
"""
Send an account reset email to the user
:param nereid_user: The browse record of the user
"""
EmailQueue = Pool().get('email.queue')
email_message = render_email(
CONFIG['smtp_from'], self.email, _('Account Password Reset'),
text_template='emails/reset-text.jinja',
html_template='emails/reset-html.jinja',
nereid_user=self
)
EmailQueue.queue_mail(
CONFIG['smtp_from'], self.email, email_message.as_string()
)
示例5: send_reset_email
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import queue_mail [as 别名]
def send_reset_email(self):
"""
Send an account reset email to the user
:param nereid_user: The browse record of the user
"""
EmailQueue = Pool().get("email.queue")
email_message = render_email(
config.get("email", "from"),
self.email,
_("Account Password Reset"),
text_template="emails/reset-text.jinja",
html_template="emails/reset-html.jinja",
nereid_user=self,
)
EmailQueue.queue_mail(config.get("email", "from"), self.email, email_message.as_string())
示例6: send_activation_email
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import queue_mail [as 别名]
def send_activation_email(self):
"""
Send an activation email to the user
:param nereid_user: The browse record of the user
"""
EmailQueue = Pool().get('email.queue')
email_message = render_email(
config.get('email', 'from'),
self.email, _('Account Activation'),
text_template='emails/activation-text.jinja',
html_template='emails/activation-html.jinja',
nereid_user=self
)
EmailQueue.queue_mail(
config.get('email', 'from'), self.email, email_message.as_string()
)
示例7: send_confirmation_email
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import queue_mail [as 别名]
def send_confirmation_email(self):
"""
An email confirming that the order has been confirmed and that we are
waiting for the payment confirmation if we are really waiting for it.
For setting a convention this email has to be sent by rendering the
templates
* Text: `<module_name>/emails/sale-confirmation-text.jinja`
* HTML: `<module_name>/emails/sale-confirmation-html.jinja`
"""
EmailQueue = Pool().get('email.queue')
Sale = Pool().get('sale.sale')
Mail = Pool().get('mail.mail')
if self.email_sent:
return
bcc_emails = self._get_bcc_emails()
to_emails = self._get_receiver_email_address()
if to_emails:
sender = config.get('email', 'from')
subject = self._get_subject_for_email()
html_template, text_template = self._get_email_template_paths()
template_context = self._get_email_template_context()
email_message = Mail.render_email(
from_email=sender,
to=', '.join(to_emails),
subject=subject,
text_template=text_template,
html_template=html_template,
sale=self,
**template_context
)
EmailQueue.queue_mail(
sender, to_emails + bcc_emails,
email_message.as_string()
)
Sale.write([self], {
'email_sent': True,
})
示例8: invitation_new_user_handler
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import queue_mail [as 别名]
def invitation_new_user_handler(nereid_user_id):
"""When the invite is sent to a new user, he is sent an invitation key
with the url which guides the user to registration page
This method checks if the invitation key is present in the url
If yes, search for the invitation with this key, attache the user
to the invitation and project to the user
If not, perform normal operation
"""
EmailQueue = Pool().get("email.queue")
try:
Invitation = Pool().get("project.work.invitation")
Project = Pool().get("project.work")
NereidUser = Pool().get("nereid.user")
Activity = Pool().get("nereid.activity")
except KeyError:
# Just return silently. This KeyError is cause if the module is not
# installed for a specific database but exists in the python path
# and is loaded by the tryton module loader
warnings.warn("nereid-project module installed but not in database", DeprecationWarning, stacklevel=2)
return
invitation_code = request.args.get("invitation_code")
if not invitation_code:
return
invitation, = Invitation.search([("invitation_code", "=", invitation_code)], limit=1)
if not invitation:
return
Invitation.write([invitation], {"nereid_user": nereid_user_id, "invitation_code": None})
nereid_user = NereidUser(nereid_user_id)
subject = "[%s] %s Accepted the invitation to join the project" % (
invitation.project.rec_name,
nereid_user.display_name,
)
receivers = [m.user.email for m in invitation.project.members if m.user.email and m.role == "admin"]
sender = config.get("email", "from")
email_message = render_email(
text_template="project/emails/invite_2_project_accepted_text.html",
subject=subject,
to=", ".join(receivers),
from_email=sender,
invitation=invitation,
)
EmailQueue.queue_mail(sender, receivers, email_message.as_string())
Project.write([invitation.project], {"members": [("create", [{"user": nereid_user_id}])]})
Activity.create(
[
{
"actor": nereid_user_id,
"object_": "project.work, %d" % invitation.project.id,
"verb": "joined_project",
"project": invitation.project.id,
}
]
)