From 4146ebaa163a1dade28460076464d774043e3655 Mon Sep 17 00:00:00 2001 From: braisab Date: Wed, 10 Nov 2021 21:05:04 +0100 Subject: [PATCH] [FIX] fixed send confirmation email from folio --- pms/models/pms_folio.py | 31 +++++++++++++++++++++++-------- pms/models/pms_property.py | 4 ++++ pms/views/pms_property_views.xml | 30 ++++++++++++++++++++++++++---- 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/pms/models/pms_folio.py b/pms/models/pms_folio.py index 68c8e769e..4223f9626 100644 --- a/pms/models/pms_folio.py +++ b/pms/models/pms_folio.py @@ -1251,14 +1251,29 @@ class PmsFolio(models.Model): if self.env.context.get("confirm_all_reservations"): self.reservation_ids.confirm() - # if self.env.context.get('send_email'): - # self.force_quotation_send() - - # create an analytic account if at least an expense product - # if any([expense_policy != 'no' for expense_policy in - # self.sale_line_ids.mapped('product_id.expense_policy')]): - # if not self.analytic_account_id: - # self._create_analytic_account() + if self.pms_property_id.is_confirmed_auto_mail: + template = self.pms_property_id.property_confirmed_template + subject = template._render_field( + "subject", [6, 0, self.id], compute_lang=True, post_process=True + )[self.id] + body = template._render_field( + "body_html", [6, 0, self.id], compute_lang=True, post_process=True + )[self.id] + invitation_mail = ( + self.env["mail.mail"] + .sudo() + .create( + { + "subject": subject, + "body_html": body, + "email_from": self.pms_property_id.partner_id.email, + "email_to": self.email, + } + ) + ) + invitation_mail.send() + for reservation in self.reservation_ids: + reservation.is_mail_send = True return True # CHECKIN/OUT PROCESS diff --git a/pms/models/pms_property.py b/pms/models/pms_property.py index 16d9209b2..01b30bf5a 100644 --- a/pms/models/pms_property.py +++ b/pms/models/pms_property.py @@ -148,6 +148,10 @@ class PmsProperty(models.Model): .id, ) + is_confirmed_auto_mail = fields.Boolean(string="Auto send mail") + is_modified_auto_mail = fields.Boolean(string="Auto send mail") + is_canceled_auto_mail = fields.Boolean(string="Auto send mail") + @api.depends_context( "checkin", "checkout", diff --git a/pms/views/pms_property_views.xml b/pms/views/pms_property_views.xml index b89e4c6d0..31f8e09e9 100644 --- a/pms/views/pms_property_views.xml +++ b/pms/views/pms_property_views.xml @@ -86,10 +86,32 @@ - - - - + +
+
+ + + + + +
+
+ + + + + +
+