[IMP]pms: added link to portal in invitation template

This commit is contained in:
braisab
2021-10-14 14:03:16 +02:00
parent d5302160e6
commit b3d57a11b8
4 changed files with 25 additions and 31 deletions

View File

@@ -619,7 +619,6 @@ class PortalPrecheckin(CustomerPortal):
checkin_partner = request.env["pms.checkin.partner"].browse( checkin_partner = request.env["pms.checkin.partner"].browse(
int(kw["checkin_partner_id"]) int(kw["checkin_partner_id"])
) )
url = kw.get("url_access_token")
firstname = kw["firstname"] firstname = kw["firstname"]
email = kw["email"] email = kw["email"]
checkin_partner.send_portal_invitation_email(url, firstname, email) checkin_partner.send_portal_invitation_email(firstname, email)

View File

@@ -6,7 +6,7 @@
<field name="model_id" ref="pms.model_pms_checkin_partner" /> <field name="model_id" ref="pms.model_pms_checkin_partner" />
<field <field
name="subject" name="subject"
>${object.pms_property_id.company_id.name} has confirmed your reservation in ${object.pms_property_id.name}</field> >Hi ${object.firstname}, do your check-in now in ${object.pms_property_id.name}</field>
<field <field
name="email_from" name="email_from"
>${object.pms_property_id.partner_id.email | safe}</field> >${object.pms_property_id.partner_id.email | safe}</field>
@@ -28,24 +28,22 @@
<table border="0" cellspacing="0" cellpadding="0"> <table border="0" cellspacing="0" cellpadding="0">
<tr> <tr>
<td align="center"> <td align="center">
<p> <a
<a href="/my/precheckin/${object.id}?access_token=${object.access_token}"
href="${object.url}" target="_blank"
target="_blank" style="text-decoration: none; color: #FFFFFF; font-size: 2em; padding: 10px 20px 10px 20px;"
style="text-decoration: none; color: #FFFFFF; font-size: 2em; padding: 10px 20px 10px 20px;" >
> <div
<div style="padding: 0.5em; background-color: #45C2B1; border-color: #45C2B1; border-width: 2px;border-style:solid; border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-style: solid;-webkit-border-radius: 10; -moz-border-radius: 10; border-radius: 10px;font-size: 12px;"
style="padding: 0.5em; background-color: #45C2B1; border-color: #45C2B1; border-width: 2px;border-style:solid; border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-style: solid;-webkit-border-radius: 10; -moz-border-radius: 10; border-radius: 10px;font-size: 12px;" >Check-in
>Check-in </div>
</div> <center><img
<center><img src="https://www.aldahotels.es/firma/email/llegada/check-in.png"
src="https://www.aldahotels.es/firma/email/llegada/check-in.png" alt="Hacer check-in"
alt="Hacer check-in" width="80px"
width="80px" height="80px"
height="80px" href="${object.url}"
href="${object.url}" /></center></a>
/></center></a>
</p>
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -767,26 +767,30 @@ class PmsCheckinPartner(models.Model):
values.update({"document_expedition_date": document_expedition_date}) values.update({"document_expedition_date": document_expedition_date})
checkin_partner.sudo().write(values) checkin_partner.sudo().write(values)
def send_portal_invitation_email(self, url, firstname=None, email=None): def send_portal_invitation_email(self, invitation_firstname=None, email=None):
subject = ( subject = (
"Hi " "Hi "
+ firstname + invitation_firstname
+ ", do your check-in now in " + ", do your check-in now in "
+ self.sudo().pms_property_id.name + self.sudo().pms_property_id.name
) )
template = self.sudo().env.ref( template = self.sudo().env.ref(
"pms.precheckin_invitation_email", raise_if_not_found=False "pms.precheckin_invitation_email", raise_if_not_found=False
) )
body = template._render_field(
"body_html", [6, 0, self.id], compute_lang=True, post_process=True
)[self.id]
invitation_mail = ( invitation_mail = (
self.env["mail.mail"] self.env["mail.mail"]
.sudo() .sudo()
.create( .create(
{ {
"subject": subject, "subject": subject,
"body_html": template.body_html, "body_html": body,
"email_from": self.pms_property_id.partner_id.email, "email_from": self.pms_property_id.partner_id.email,
"email_to": email, "email_to": email,
} }
) )
) )
invitation_mail.send() invitation_mail.send()

View File

@@ -27,19 +27,12 @@ odoo.define("pms.SendInvitationData", function (require) {
.parent() .parent()
.find("input[name=invitation_email]") .find("input[name=invitation_email]")
.val(); .val();
var urlAccessToken = $(ev.currentTarget)
.parent()
.parent()
.parent()
.find("a[name=url_acess_token]")
.attr("href");
this._rpc({ this._rpc({
route: "/my/precheckin/send_invitation", route: "/my/precheckin/send_invitation",
params: { params: {
checkin_partner_id: checkinPartnerId, checkin_partner_id: checkinPartnerId,
firstname: firstname, firstname: firstname,
email: email, email: email,
url_access_token: urlAccessToken,
}, },
}); });
}, },