[IMP]pms_api_rest: added mail template to reset paswword

This commit is contained in:
braisab
2023-05-29 14:12:43 +02:00
committed by Darío Lodeiros
parent 94d832e3b3
commit 932f01f9e2
3 changed files with 101 additions and 1 deletions

View File

@@ -22,6 +22,7 @@
"data": [
"data/sql_reports.xml",
"data/auth_jwt_validator.xml",
"data/pms_app_reset_password_template.xml",
"views/pms_property_views.xml",
"views/res_users_views.xml",
],

View File

@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="pms_reset_password_email" model="mail.template">
<field name="name">Pms Reset Password</field>
<field name="model_id" ref="base.model_res_users"/>
<field name="subject">Restablecer Contraseña</field>
<field name="email_from">"${object.company_id.name | safe}" &lt;${(object.company_id.email or user.email) | safe}&gt;</field>
<field name="email_to">${object.email_formatted | safe}</field>
<field name="body_html" type="html">
<table border="0" cellpadding="0" cellspacing="0" style=" font-family:Verdana, Arial,sans-serif; color: #454748; width: 100%; border-collapse:separate;"><tr><td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="590" style="background-color: white; color: #454748; border-collapse:separate; font-family:Verdana, font-family:Verdana, Arial,sans-serif; box-shadow: rgb(0 0 0 / 24%) 0px 3px 8px; border-radius: 24px">
<tbody>
<!-- HEADER -->
<tr>
<td align="center" style="min-width: 590px;">
<table border="0" cellpadding="0" cellspacing="0" width="590" height="100" style="min-width: 590px; background-color: #4BB1E0; color:white; border-collapse:separate; border-radius: 24px 24px 0 0">
<tr>
<td valign="middle" align="middle">
<span style="font-size: 24px; font-weight: bold;">
ROOMDOO
</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" style="min-width: 590px;">
<table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; border-collapse:separate;padding: 24px 24px 0 24px; margin-bottom: 24px;">
<tr><td valign="middle">
<span style="font-size: 20px; font-weight: bold;">
${object.name}
</span>
</td><td valign="middle" align="right">
<img src="/logo.png?company=${object.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${object.company_id.name}"/>
</td></tr>
</table>
</td>
</tr>
<!-- CONTENT -->
<tr>
<td align="center" style="min-width: 590px;">
<table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 24px; border-collapse:separate; margin-bottom: 40px">
<tr><td valign="top" style="font-size: 13px;">
<div>
A password reset was requested for the Odoo account linked to this email.
You may change your password by following this link which will remain valid during 15 minutes:
<br/>
<div style="margin: 32px 0">
<a href="${ctx.get('app_url')}/reset-password?token=${object.signup_token}"
style="background-color: #4BB1E0; padding: 8px 16px 8px 16px; text-decoration: none; color: #fff; border-radius: 5px; font-size:13px;">
Reestablecer contraseña
</a>
</div>
If you do not expect this, you can safely ignore this email.<br/><br/>
Thanks,
% if user.signature:
<br/>
${user.signature | safe}
% endif
</div>
</td></tr>
</table>
</td>
</tr>
<!-- FOOTER -->
<tr>
<td align="center" style="min-width: 590px;">
<table border="0" cellpadding="0" cellspacing="0" width="590" style="border-radius: 0 0 24px 24px;min-width: 590px; background-color: white; font-size: 11px; padding: 0 24px 24px 24px; border-collapse:separate;">
<tr><td valign="middle" align="left">
${object.company_id.name}
</td></tr>
<tr><td valign="middle" align="left" style="opacity: 0.7;">
${object.company_id.phone}
% if object.company_id.email
| <a href="'mailto:%s' % ${object.company_id.email}" style="text-decoration:none; color: #454748;">${object.company_id.email}</a>
% endif
% if object.company_id.website
| <a href="'%s' % ${object.company_id.website}" style="text-decoration:none; color: #454748;">
${object.company_id.website}
</a>
% endif
</td></tr>
</table>
</td>
</tr>
</tbody>
</table>
</td></tr>
</table>
</field>
<field name="lang">${object.lang}</field>
<field name="auto_delete" eval="True"/>
</record>
</data>
</odoo>

View File

@@ -166,7 +166,7 @@ class PmsRoomTypeClassService(Component):
def send_mail_to_reset_password(self, input_data):
user = self.env["res.users"].sudo().search([("email", "=", input_data.userEmail)])
if user:
template_id = self.env.ref("pms.pms_reset_password_email").id
template_id = self.env.ref("pms_api_rest.pms_reset_password_email").id
template = self.env['mail.template'].sudo().browse(template_id)
if not template:
return False