mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX]pms: fixed sending of email from the reservation model
This commit is contained in:
@@ -36,8 +36,10 @@ class MailComposeMessage(models.TransientModel):
|
|||||||
# folio.reservation_ids = cmds
|
# folio.reservation_ids = cmds
|
||||||
res = super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)
|
res = super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)
|
||||||
if self._context.get("record_id"):
|
if self._context.get("record_id"):
|
||||||
reservation = self.env["pms.reservation"].search(
|
folio = self.env["pms.folio"].search(
|
||||||
[("id", "=", self._context.get("record_id"))]
|
[("id", "=", self._context.get("record_id"))]
|
||||||
)
|
)
|
||||||
reservation.is_mail_send = True
|
reservations = folio.reservation_ids
|
||||||
|
for reservation in reservations:
|
||||||
|
reservation.is_mail_send = True
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -1727,38 +1727,36 @@ class PmsReservation(models.Model):
|
|||||||
def action_open_mail_composer(self):
|
def action_open_mail_composer(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
template = False
|
template = False
|
||||||
|
pms_property = self.pms_property_id
|
||||||
if (
|
if (
|
||||||
not self.is_mail_send
|
not self.is_mail_send
|
||||||
and not self.is_modified_reservation
|
and not self.is_modified_reservation
|
||||||
and self.state not in "cancel"
|
and self.state not in "cancel"
|
||||||
):
|
):
|
||||||
template = self.env.ref(
|
if pms_property.property_confirmed_template:
|
||||||
"pms.confirmed_reservation_email", raise_if_not_found=False
|
template = pms_property.property_confirmed_template
|
||||||
)
|
|
||||||
elif (
|
elif (
|
||||||
not self.is_mail_send
|
not self.is_mail_send
|
||||||
and self.is_modified_reservation
|
and self.is_modified_reservation
|
||||||
and self.state not in "cancel"
|
and self.state not in "cancel"
|
||||||
):
|
):
|
||||||
template = self.env.ref(
|
if pms_property.property_modified_template:
|
||||||
"pms.modified_reservation_email", raise_if_not_found=False
|
template = pms_property.property_modified_template
|
||||||
)
|
|
||||||
elif not self.is_mail_send and self.state in "cancel":
|
elif not self.is_mail_send and self.state in "cancel":
|
||||||
template = self.env.ref(
|
if pms_property.property_canceled_template:
|
||||||
"pms.cancelled_reservation_email", raise_if_not_found=False
|
template = pms_property.property_canceled_template
|
||||||
)
|
|
||||||
compose_form = self.env.ref(
|
compose_form = self.env.ref(
|
||||||
"mail.email_compose_message_wizard_form", raise_if_not_found=False
|
"mail.email_compose_message_wizard_form", raise_if_not_found=False
|
||||||
)
|
)
|
||||||
ctx = dict(
|
ctx = dict(
|
||||||
model="pms.reservation",
|
model="pms.folio",
|
||||||
default_res_model="pms.reservation",
|
default_res_model="pms.folio",
|
||||||
default_res_id=self.id,
|
default_res_id=self.folio_id.id,
|
||||||
template_id=template and template.id or False,
|
template_id=template and template.id or False,
|
||||||
composition_mode="comment",
|
composition_mode="comment",
|
||||||
partner_ids=[self.partner_id.id],
|
partner_ids=[self.partner_id.id],
|
||||||
force_email=True,
|
force_email=True,
|
||||||
record_id=self.id,
|
record_id=self.folio_id.id,
|
||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
"name": _("Send Confirmed Reservation Mail "),
|
"name": _("Send Confirmed Reservation Mail "),
|
||||||
|
|||||||
Reference in New Issue
Block a user