mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[REF] changed field is_mail_send to to_send_mail
This commit is contained in:
2
pms/migrations/14.0.2.22.1/post-migrate.py
Normal file
2
pms/migrations/14.0.2.22.1/post-migrate.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def migrate(cr, version):
|
||||
cr.execute("UPDATE pms_reservation SET to_send_mail = NOT is_mail_send")
|
||||
@@ -21,19 +21,6 @@ class MailComposeMessage(models.TransientModel):
|
||||
return res
|
||||
|
||||
def send_mail(self, auto_commit=False):
|
||||
# if (
|
||||
# self._context.get("default_model") == "pms.folio"
|
||||
# and self._context.get("default_res_id")
|
||||
# and self._context.get("mark_so_as_sent")
|
||||
# ):
|
||||
# # TODO: WorkFlow Mails
|
||||
# folio = self.env["pms.folio"].browse([self._context["default_res_id"]])
|
||||
# if folio:
|
||||
# cmds = [
|
||||
# (1, lid, {"to_send": False}) for lid in folio.reservation_ids.ids
|
||||
# ]
|
||||
# if any(cmds):
|
||||
# folio.reservation_ids = cmds
|
||||
res = super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)
|
||||
if self._context.get("record_id"):
|
||||
folio = self.env["pms.folio"].search(
|
||||
@@ -41,5 +28,5 @@ class MailComposeMessage(models.TransientModel):
|
||||
)
|
||||
reservations = folio.reservation_ids
|
||||
for reservation in reservations:
|
||||
reservation.is_mail_send = True
|
||||
reservation.to_send_mail = False
|
||||
return res
|
||||
|
||||
@@ -516,13 +516,6 @@ class PmsFolio(models.Model):
|
||||
compute="_compute_last_checkout",
|
||||
)
|
||||
|
||||
date_creation = fields.Date(
|
||||
string="Creation Date",
|
||||
readonly=False,
|
||||
store=True,
|
||||
compute="_compute_date_creation",
|
||||
)
|
||||
|
||||
def name_get(self):
|
||||
result = []
|
||||
for folio in self:
|
||||
@@ -1302,18 +1295,17 @@ class PmsFolio(models.Model):
|
||||
|
||||
@api.model
|
||||
def send_confirmation_mail(self):
|
||||
today = fields.Date.today()
|
||||
folios = self.env["pms.folio"].search(
|
||||
[
|
||||
("reservation_type", "!=", "out"),
|
||||
("pms_property_id.is_confirmed_auto_mail", "=", True),
|
||||
("reservation_ids.is_mail_send", "=", False),
|
||||
("reservation_ids.to_send_mail", "=", True),
|
||||
("reservation_ids.is_modified_reservation", "=", False),
|
||||
("date_creation", "=", today),
|
||||
("reservation_ids.state", "!=", "cancel"),
|
||||
]
|
||||
)
|
||||
for folio in folios:
|
||||
if folio.email:
|
||||
if folio.email and folio.create_date.date() == fields.Date.today():
|
||||
template = folio.pms_property_id.property_confirmed_template
|
||||
subject = template._render_field(
|
||||
"subject",
|
||||
@@ -1352,7 +1344,7 @@ class PmsFolio(models.Model):
|
||||
}
|
||||
)
|
||||
for reservation in folio.reservation_ids:
|
||||
reservation.is_mail_send = True
|
||||
reservation.to_send_mail = False
|
||||
|
||||
@api.model
|
||||
def send_modification_mail(self):
|
||||
@@ -1360,8 +1352,9 @@ class PmsFolio(models.Model):
|
||||
[
|
||||
("reservation_type", "!=", "out"),
|
||||
("pms_property_id.is_modified_auto_mail", "=", True),
|
||||
("reservation_ids.is_mail_send", "=", False),
|
||||
("reservation_ids.to_send_mail", "=", True),
|
||||
("reservation_ids.is_modified_reservation", "=", True),
|
||||
("reservation_ids.state", "!=", "cancel"),
|
||||
]
|
||||
)
|
||||
for folio in folios:
|
||||
@@ -1406,7 +1399,7 @@ class PmsFolio(models.Model):
|
||||
}
|
||||
)
|
||||
for reservation in folio.reservation_ids:
|
||||
reservation.is_mail_send = True
|
||||
reservation.to_send_mail = False
|
||||
|
||||
@api.model
|
||||
def send_cancelation_mail(self):
|
||||
@@ -1418,7 +1411,7 @@ class PmsFolio(models.Model):
|
||||
for reservation in reservations:
|
||||
if reservation.email:
|
||||
if (
|
||||
not reservation.is_mail_send
|
||||
not reservation.to_send_mail
|
||||
and reservation.email
|
||||
and reservation.state not in "out"
|
||||
):
|
||||
@@ -1463,7 +1456,7 @@ class PmsFolio(models.Model):
|
||||
"message": "Cancellation Mail Delivery Failed",
|
||||
}
|
||||
)
|
||||
reservation.is_mail_send = True
|
||||
reservation.to_send_mail = False
|
||||
|
||||
def action_view_invoice(self):
|
||||
invoices = self.mapped("move_ids")
|
||||
|
||||
@@ -643,7 +643,7 @@ class PmsReservation(models.Model):
|
||||
comodel_name="res.partner",
|
||||
inverse_name="reservation_possible_customer_id",
|
||||
)
|
||||
is_mail_send = fields.Boolean(string="Mail Sent", default=False)
|
||||
to_send_mail = fields.Boolean(string="Mail Sent", default=True)
|
||||
|
||||
is_modified_reservation = fields.Boolean(
|
||||
string="Is A Modified Reservation",
|
||||
@@ -1470,9 +1470,9 @@ class PmsReservation(models.Model):
|
||||
for record in self:
|
||||
if record.state in "draft":
|
||||
record.is_modified_reservation = False
|
||||
elif record.state in ("confirm", "onboard") and record.is_mail_send:
|
||||
elif record.state in ("confirm", "onboard") and not record.to_send_mail:
|
||||
record.is_modified_reservation = True
|
||||
record.is_mail_send = False
|
||||
record.to_send_mail = True
|
||||
else:
|
||||
record.is_modified_reservation = False
|
||||
|
||||
@@ -1730,20 +1730,20 @@ class PmsReservation(models.Model):
|
||||
template = False
|
||||
pms_property = self.pms_property_id
|
||||
if (
|
||||
not self.is_mail_send
|
||||
self.to_send_mail
|
||||
and not self.is_modified_reservation
|
||||
and self.state not in "cancel"
|
||||
):
|
||||
if pms_property.property_confirmed_template:
|
||||
template = pms_property.property_confirmed_template
|
||||
elif (
|
||||
not self.is_mail_send
|
||||
self.to_send_mail
|
||||
and self.is_modified_reservation
|
||||
and self.state not in "cancel"
|
||||
):
|
||||
if pms_property.property_modified_template:
|
||||
template = pms_property.property_modified_template
|
||||
elif not self.is_mail_send and self.state in "cancel":
|
||||
elif self.to_send_mail and self.state in "cancel":
|
||||
if pms_property.property_canceled_template:
|
||||
template = pms_property.property_canceled_template
|
||||
compose_form = self.env.ref(
|
||||
@@ -1931,7 +1931,7 @@ class PmsReservation(models.Model):
|
||||
else:
|
||||
record.state = "cancel"
|
||||
record.folio_id._compute_amount()
|
||||
record.is_mail_send = False
|
||||
record.to_send_mail = True
|
||||
|
||||
def action_assign(self):
|
||||
for record in self:
|
||||
|
||||
@@ -3462,7 +3462,7 @@ class TestPmsReservations(TestPms):
|
||||
----------------------
|
||||
A reservation is created. The checkin and checkout fields of
|
||||
the reservation are modified. The state of the boolean
|
||||
is_mail_send is changed to True so that the compute of
|
||||
to_send_mail is changed to False so that the compute of
|
||||
the is_modified_reservation field is activated correctly
|
||||
and it is verified that the state of this field is True.
|
||||
"""
|
||||
@@ -3482,7 +3482,7 @@ class TestPmsReservations(TestPms):
|
||||
# ACT
|
||||
writed_checkin = fields.date.today() + datetime.timedelta(days=4)
|
||||
writed_checkout = fields.date.today() + datetime.timedelta(days=6)
|
||||
reservation.is_mail_send = True
|
||||
reservation.to_send_mail = False
|
||||
reservation.update(
|
||||
{
|
||||
"checkin": writed_checkin,
|
||||
|
||||
@@ -47,22 +47,22 @@
|
||||
name="action_open_mail_composer"
|
||||
string="Send Confirmation Email "
|
||||
type="object"
|
||||
attrs="{'invisible':['|','|',('is_mail_send', '=', True),('is_modified_reservation', '=', True),('state', 'in', 'cancel')]}"
|
||||
attrs="{'invisible':['|','|',('to_send_mail', '=', False),('is_modified_reservation', '=', True),('state', 'in', 'cancel')]}"
|
||||
/>
|
||||
<button
|
||||
name="action_open_mail_composer"
|
||||
string="Send Modification Email "
|
||||
type="object"
|
||||
attrs="{'invisible':['|','|',('is_mail_send', '=', True), ('is_modified_reservation', '=', False), ('state', 'in', 'cancel')]}"
|
||||
attrs="{'invisible':['|','|',('to_send_mail', '=', False), ('is_modified_reservation', '=', False), ('state', 'in', 'cancel')]}"
|
||||
/>
|
||||
<button
|
||||
name="action_open_mail_composer"
|
||||
string="Send Cancellation Email "
|
||||
type="object"
|
||||
attrs="{'invisible':['|',('is_mail_send', '=', True), ('state', 'not in', 'cancel')]}"
|
||||
attrs="{'invisible':['|',('to_send_mail', '=', False), ('state', 'not in', 'cancel')]}"
|
||||
/>
|
||||
<field name="state" widget="statusbar" />
|
||||
<field name="is_mail_send" invisible="1" />
|
||||
<field name="to_send_mail" invisible="1" />
|
||||
<field name="is_modified_reservation" invisible="1" />
|
||||
</header>
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user