mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: refactor workflow mails
This commit is contained in:
@@ -86,7 +86,6 @@
|
|||||||
"views/traveller_report_template.xml",
|
"views/traveller_report_template.xml",
|
||||||
"views/assets.xml",
|
"views/assets.xml",
|
||||||
"wizards/wizard_split_join_swap_reservation.xml",
|
"wizards/wizard_split_join_swap_reservation.xml",
|
||||||
"views/pms_automated_mails_views.xml",
|
|
||||||
"views/precheckin_portal_templates.xml",
|
"views/precheckin_portal_templates.xml",
|
||||||
"wizards/wizard_massive_changes.xml",
|
"wizards/wizard_massive_changes.xml",
|
||||||
"wizards/wizard_advanced_filters.xml",
|
"wizards/wizard_advanced_filters.xml",
|
||||||
|
|||||||
@@ -145,39 +145,5 @@ else:
|
|||||||
failed = True
|
failed = True
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<!-- pms.automated_mails-->
|
|
||||||
<record id="pms_auto_mail_confirm" model="pms.automated.mails">
|
|
||||||
<field name="name">Confirmed Reservation</field>
|
|
||||||
<field name="active">False</field>
|
|
||||||
<field name="template_id" ref="pms.confirmed_reservation_email" />
|
|
||||||
<field name="action">creation</field>
|
|
||||||
<field
|
|
||||||
name="pms_property_ids"
|
|
||||||
eval="[(6, False, [ref('main_pms_property')])]"
|
|
||||||
/>
|
|
||||||
<field name="moment">in_act</field>
|
|
||||||
</record>
|
|
||||||
<record id="pms_auto_mail_write" model="pms.automated.mails">
|
|
||||||
<field name="name">Modified Reservation</field>
|
|
||||||
<field name="active">False</field>
|
|
||||||
<field name="template_id" ref="pms.modified_reservation_email" />
|
|
||||||
<field name="action">write</field>
|
|
||||||
<field
|
|
||||||
name="pms_property_ids"
|
|
||||||
eval="[(6, False, [ref('main_pms_property')])]"
|
|
||||||
/>
|
|
||||||
<field name="moment">in_act</field>
|
|
||||||
</record>
|
|
||||||
<record id="pms_auto_mail_cancel" model="pms.automated.mails">
|
|
||||||
<field name="name">Cancelled Reservation</field>
|
|
||||||
<field name="active">False</field>
|
|
||||||
<field name="template_id" ref="pms.cancelled_reservation_email" />
|
|
||||||
<field name="action">cancel</field>
|
|
||||||
<field
|
|
||||||
name="pms_property_ids"
|
|
||||||
eval="[(6, False, [ref('main_pms_property')])]"
|
|
||||||
/>
|
|
||||||
<field name="moment">in_act</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -5357,11 +5357,6 @@ msgstr ""
|
|||||||
msgid "Invoicing Policy"
|
msgid "Invoicing Policy"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: pms
|
|
||||||
#: model:ir.model.fields,field_description:pms.field_pms_reservation__is_modified_reservation
|
|
||||||
msgid "Is A Modified Reservation"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: pms
|
#. module: pms
|
||||||
#: model:ir.model.fields,field_description:pms.field_pms_property__is_agency
|
#: model:ir.model.fields,field_description:pms.field_pms_property__is_agency
|
||||||
#: model:ir.model.fields,field_description:pms.field_res_partner__is_agency
|
#: model:ir.model.fields,field_description:pms.field_res_partner__is_agency
|
||||||
@@ -10691,11 +10686,6 @@ msgstr ""
|
|||||||
msgid "To Invoice Quantity"
|
msgid "To Invoice Quantity"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: pms
|
|
||||||
#: model:ir.model.fields,field_description:pms.field_pms_reservation__to_send_mail
|
|
||||||
msgid "To Send Mail"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: pms
|
#. module: pms
|
||||||
#: model_terms:ir.ui.view,arch_db:pms.pms_reservation_view_search
|
#: model_terms:ir.ui.view,arch_db:pms.pms_reservation_view_search
|
||||||
msgid "To be paid"
|
msgid "To be paid"
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
def migrate(cr, version):
|
|
||||||
cr.execute("UPDATE pms_reservation SET to_send_mail = NOT is_mail_send")
|
|
||||||
@@ -16,21 +16,5 @@ class MailComposeMessage(models.TransientModel):
|
|||||||
folio = self.env["pms.folio"].browse(self._context.get("default_res_id"))
|
folio = self.env["pms.folio"].browse(self._context.get("default_res_id"))
|
||||||
reservations = folio.reservation_ids
|
reservations = folio.reservation_ids
|
||||||
for reservation in reservations:
|
for reservation in reservations:
|
||||||
reservation.to_send_mail = False
|
reservation.to_send_confirmation_mail = False
|
||||||
elif (
|
|
||||||
self._context.get("default_model") == "pms.reservation"
|
|
||||||
or self._context.get("default_model") == "pms.checkin.partner"
|
|
||||||
) and self._context.get("active_model") == "pms.reservation":
|
|
||||||
reservation = self.env["pms.reservation"].browse(
|
|
||||||
self._context.get("active_id")
|
|
||||||
)
|
|
||||||
reservation.to_send_mail = False
|
|
||||||
elif (
|
|
||||||
self._context.get("default_model") == "pms.checkin.partner"
|
|
||||||
and self._context.get("active_model") == "pms.reservation"
|
|
||||||
):
|
|
||||||
reservation = self.env["pms.reservation"].search(
|
|
||||||
self._context.get("default_res_id")
|
|
||||||
)
|
|
||||||
reservation.to_send_mail = False
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -1,388 +1,9 @@
|
|||||||
from odoo import _, api, fields, models
|
from odoo import fields, models
|
||||||
from odoo.exceptions import UserError
|
|
||||||
|
|
||||||
|
|
||||||
class PmsAutomatedMails(models.Model):
|
class PmsAutomatedMails(models.Model):
|
||||||
_name = "pms.automated.mails"
|
_name = "pms.automated.mails"
|
||||||
_description = "Automatic Mails"
|
_description = "Automatic Mails"
|
||||||
|
|
||||||
|
# TODO: Model to delete
|
||||||
name = fields.Char(string="Name", help="Name of the automated mail.", required=True)
|
name = fields.Char(string="Name", help="Name of the automated mail.", required=True)
|
||||||
|
|
||||||
pms_property_ids = fields.Many2many(
|
|
||||||
string="Property",
|
|
||||||
help="Properties with access to the element;"
|
|
||||||
" if not set, all properties can access",
|
|
||||||
comodel_name="pms.property",
|
|
||||||
)
|
|
||||||
|
|
||||||
automated_actions_id = fields.Many2one(
|
|
||||||
string="Automated Actions",
|
|
||||||
help="automated action that is created when creating automated emails ",
|
|
||||||
comodel_name="base.automation",
|
|
||||||
)
|
|
||||||
|
|
||||||
time = fields.Integer(string="Time", help="Amount of time")
|
|
||||||
|
|
||||||
time_type = fields.Selection(
|
|
||||||
string="Time Range",
|
|
||||||
help="Type of date range",
|
|
||||||
selection=[
|
|
||||||
("minutes", "Minutes"),
|
|
||||||
("hour", "Hour"),
|
|
||||||
("day", "Days"),
|
|
||||||
("month", "Months"),
|
|
||||||
],
|
|
||||||
default="day",
|
|
||||||
)
|
|
||||||
template_id = fields.Many2one(
|
|
||||||
string="Template",
|
|
||||||
help="The template that will be sent by email",
|
|
||||||
comodel_name="mail.template",
|
|
||||||
required=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
action = fields.Selection(
|
|
||||||
string="Action",
|
|
||||||
help="The action that will cause the email to be sent ",
|
|
||||||
selection=[
|
|
||||||
("creation", "Reservation creation"),
|
|
||||||
("write", "Reservation modification"),
|
|
||||||
("cancel", "Reservation cancellation"),
|
|
||||||
("checkin", "Checkin"),
|
|
||||||
("checkout", "Checkout"),
|
|
||||||
("payment", "Payment"),
|
|
||||||
("invoice", "Invoice"),
|
|
||||||
],
|
|
||||||
default="creation",
|
|
||||||
required=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
moment = fields.Selection(
|
|
||||||
string="Moment",
|
|
||||||
help="Moment in relation to the action in which the email will be sent",
|
|
||||||
selection=[
|
|
||||||
("in_act", "In the act"),
|
|
||||||
("before", "Before"),
|
|
||||||
("after", "After"),
|
|
||||||
],
|
|
||||||
default="in_act",
|
|
||||||
)
|
|
||||||
|
|
||||||
active = fields.Boolean(
|
|
||||||
string="Active", help="Indicates if the automated mail is active", default=True
|
|
||||||
)
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def create(self, vals):
|
|
||||||
name = vals.get("name")
|
|
||||||
action = vals.get("action")
|
|
||||||
time = vals.get("time")
|
|
||||||
date_range_type = vals.get("time_type")
|
|
||||||
template_id = vals.get("template_id")
|
|
||||||
active = vals.get("active")
|
|
||||||
moment = vals.get("moment")
|
|
||||||
properties = vals.get("pms_property_ids")
|
|
||||||
is_create = True
|
|
||||||
if action in ("creation", "write", "cancel", "invoice") and moment == "before":
|
|
||||||
raise UserError(_("The moment for this action cannot be 'Before'"))
|
|
||||||
dict_val = self._prepare_automated_actions_id(
|
|
||||||
action, time, moment, properties, is_create
|
|
||||||
)
|
|
||||||
action_server_vals = {
|
|
||||||
"name": name,
|
|
||||||
"state": "email",
|
|
||||||
"usage": "ir_cron",
|
|
||||||
"model_id": dict_val["model_id"],
|
|
||||||
}
|
|
||||||
if action == "checkout":
|
|
||||||
code = "record.send_exit_email(" + str(template_id) + ")"
|
|
||||||
action_server_vals.update({"state": "code", "code": code})
|
|
||||||
action_server = self.env["ir.actions.server"].create(action_server_vals)
|
|
||||||
automated_actions_vals = {
|
|
||||||
"active": active,
|
|
||||||
"action_server_id": action_server.id,
|
|
||||||
"trigger": dict_val["trigger"],
|
|
||||||
"filter_domain": dict_val["filter_domain"],
|
|
||||||
"filter_pre_domain": dict_val["filter_pre_domain"],
|
|
||||||
"trg_date_range": dict_val["time"],
|
|
||||||
"trg_date_range_type": date_range_type,
|
|
||||||
"template_id": template_id,
|
|
||||||
}
|
|
||||||
model_field = dict_val["model_field"]
|
|
||||||
if model_field:
|
|
||||||
automated_actions_vals.update(
|
|
||||||
{
|
|
||||||
"trg_date_id": dict_val["model_field"].id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
trigger_field = dict_val["trigger_fields"]
|
|
||||||
if trigger_field:
|
|
||||||
automated_actions_vals.update(
|
|
||||||
{
|
|
||||||
"trigger_field_ids": dict_val["trigger_fields"].ids,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
automated_action = self.env["base.automation"].create(automated_actions_vals)
|
|
||||||
vals.update({"automated_actions_id": automated_action.id})
|
|
||||||
return super(PmsAutomatedMails, self).create(vals)
|
|
||||||
|
|
||||||
def write(self, vals):
|
|
||||||
result = super(PmsAutomatedMails, self).write(vals)
|
|
||||||
is_create = False
|
|
||||||
if (
|
|
||||||
self.action in ("creation", "write", "cancel", "invoice", "checkout")
|
|
||||||
and self.moment == "before"
|
|
||||||
):
|
|
||||||
raise UserError(_("The moment for this action cannot be 'Before'"))
|
|
||||||
dict_val = self._prepare_automated_actions_id(
|
|
||||||
self.action, self.time, self.moment, self.pms_property_ids, is_create
|
|
||||||
)
|
|
||||||
automated_actions_id = self.automated_actions_id
|
|
||||||
action_server = automated_actions_id.action_server_id
|
|
||||||
action_server_vals = {
|
|
||||||
"name": self.name,
|
|
||||||
"state": "email",
|
|
||||||
"usage": "ir_cron",
|
|
||||||
"model_id": dict_val["model_id"],
|
|
||||||
}
|
|
||||||
if vals.get("action") == "checkout":
|
|
||||||
code = "record.send_exit_email(" + str(self.template_id) + ")"
|
|
||||||
action_server_vals.update({"state": "code", "code": code})
|
|
||||||
action_server.write(action_server_vals)
|
|
||||||
automated_actions_vals = {
|
|
||||||
"active": self.active,
|
|
||||||
"action_server_id": action_server.id,
|
|
||||||
"trigger": dict_val["trigger"],
|
|
||||||
"filter_domain": dict_val["filter_domain"],
|
|
||||||
"filter_pre_domain": dict_val["filter_pre_domain"],
|
|
||||||
"trg_date_range": dict_val["time"],
|
|
||||||
"trg_date_range_type": self.time_type,
|
|
||||||
"template_id": self.template_id,
|
|
||||||
}
|
|
||||||
model_field = dict_val["model_field"]
|
|
||||||
if model_field:
|
|
||||||
automated_actions_vals.update(
|
|
||||||
{
|
|
||||||
"trg_date_id": dict_val["model_field"].id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
trigger_field = dict_val["trigger_fields"]
|
|
||||||
if trigger_field:
|
|
||||||
automated_actions_vals.update(
|
|
||||||
{
|
|
||||||
"trigger_field_ids": dict_val["trigger_fields"].ids,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
automated_actions_id.write(automated_actions_vals)
|
|
||||||
vals.update({"automated_actions_id": automated_actions_id.id})
|
|
||||||
return result
|
|
||||||
|
|
||||||
def unlink(self):
|
|
||||||
automated_actions_id = self.automated_actions_id
|
|
||||||
action_server = automated_actions_id.action_server_id
|
|
||||||
automated_actions_id.unlink()
|
|
||||||
action_server.unlink()
|
|
||||||
return super(PmsAutomatedMails, self).unlink()
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _get_auto_action_fields_in_creation_action(self, moment, time):
|
|
||||||
model_field = False
|
|
||||||
model_id = self.env["ir.model"].search([("model", "=", "pms.folio")]).id
|
|
||||||
if moment == "in_act":
|
|
||||||
trigger = "on_create"
|
|
||||||
time = 0
|
|
||||||
else:
|
|
||||||
trigger = "on_time"
|
|
||||||
model_field = self.env["ir.model.fields"].search(
|
|
||||||
[("model", "=", "pms.folio"), ("name", "=", "create_date")]
|
|
||||||
)
|
|
||||||
result = {
|
|
||||||
"model_id": model_id,
|
|
||||||
"trigger": trigger,
|
|
||||||
"model_field": model_field,
|
|
||||||
"time": time,
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _get_auto_action_fields_in_write_or_cancel_action(self, moment, time):
|
|
||||||
model_field = False
|
|
||||||
model_id = self.env["ir.model"].search([("model", "=", "pms.reservation")]).id
|
|
||||||
if moment == "in_act":
|
|
||||||
trigger = "on_write"
|
|
||||||
time = 0
|
|
||||||
else:
|
|
||||||
trigger = "on_time"
|
|
||||||
model_field = self.env["ir.model.fields"].search(
|
|
||||||
[("model", "=", "pms.reservation"), ("name", "=", "write_date")]
|
|
||||||
)
|
|
||||||
result = {
|
|
||||||
"model_id": model_id,
|
|
||||||
"trigger": trigger,
|
|
||||||
"model_field": model_field,
|
|
||||||
"time": time,
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _get_auto_action_fields_in_checkin_action(self, moment, time):
|
|
||||||
model_id = self.env["ir.model"].search([("model", "=", "pms.reservation")]).id
|
|
||||||
trigger = "on_time"
|
|
||||||
model_field = self.env["ir.model.fields"].search(
|
|
||||||
[("model", "=", "pms.reservation"), ("name", "=", "checkin")]
|
|
||||||
)
|
|
||||||
if moment == "before":
|
|
||||||
time = time * (-1)
|
|
||||||
if moment == "in_act":
|
|
||||||
trigger = "on_write"
|
|
||||||
time = 0
|
|
||||||
result = {
|
|
||||||
"model_id": model_id,
|
|
||||||
"trigger": trigger,
|
|
||||||
"model_field": model_field,
|
|
||||||
"time": time,
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _get_auto_action_fields_in_checkout_action(self, moment, time):
|
|
||||||
model_id = (
|
|
||||||
self.env["ir.model"].search([("model", "=", "pms.checkin.partner")]).id
|
|
||||||
)
|
|
||||||
trigger = "on_write"
|
|
||||||
model_field = self.env["ir.model.fields"].search(
|
|
||||||
[("model", "=", "pms.checkin.partner"), ("name", "=", "state")]
|
|
||||||
)
|
|
||||||
if moment == "in_act":
|
|
||||||
time = 0
|
|
||||||
else:
|
|
||||||
trigger = "on_time"
|
|
||||||
model_field = self.env["ir.model.fields"].search(
|
|
||||||
[("model", "=", "pms.checkin.partner"), ("name", "=", "departure")]
|
|
||||||
)
|
|
||||||
result = {
|
|
||||||
"model_id": model_id,
|
|
||||||
"trigger": trigger,
|
|
||||||
"model_field": model_field,
|
|
||||||
"time": time,
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _get_auto_action_fields_in_payment_action(self, moment, time):
|
|
||||||
model_field = False
|
|
||||||
model_id = (
|
|
||||||
self.env["ir.model"]
|
|
||||||
.search([("model", "=", "account.payment"), ("transient", "=", False)])
|
|
||||||
.id
|
|
||||||
)
|
|
||||||
if moment == "in_act":
|
|
||||||
trigger = "on_create"
|
|
||||||
time = 0
|
|
||||||
else:
|
|
||||||
trigger = "on_time"
|
|
||||||
model_field = self.env["ir.model.fields"].search(
|
|
||||||
[("model", "=", "account.payment"), ("name", "=", "date")]
|
|
||||||
)
|
|
||||||
if moment == "before":
|
|
||||||
time = time * (-1)
|
|
||||||
result = {
|
|
||||||
"model_id": model_id,
|
|
||||||
"trigger": trigger,
|
|
||||||
"model_field": model_field,
|
|
||||||
"time": time,
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _get_auto_action_fields_in_invoice_action(self, moment, time):
|
|
||||||
trigger = False
|
|
||||||
model_id = self.env["ir.model"].search([("model", "=", "account.move")]).id
|
|
||||||
if moment == "in_act":
|
|
||||||
trigger = "on_create"
|
|
||||||
time = 0
|
|
||||||
result = {
|
|
||||||
"model_id": model_id,
|
|
||||||
"time": time,
|
|
||||||
"trigger": trigger,
|
|
||||||
"model_field": False,
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
|
|
||||||
def _prepare_automated_actions_id(
|
|
||||||
self, action, time, moment, properties, is_create
|
|
||||||
):
|
|
||||||
filter_domain = []
|
|
||||||
filter_pre_domain = []
|
|
||||||
trigger_fields = False
|
|
||||||
dict_val = {}
|
|
||||||
if action == "creation":
|
|
||||||
dict_val = self._get_auto_action_fields_in_creation_action(moment, time)
|
|
||||||
filter_domain = [
|
|
||||||
("first_checkin", ">=", str(fields.date.today())),
|
|
||||||
("reservation_ids.to_send_mail", "=", True),
|
|
||||||
]
|
|
||||||
elif action == "write" or action == "cancel":
|
|
||||||
dict_val = self._get_auto_action_fields_in_write_or_cancel_action(
|
|
||||||
moment, time
|
|
||||||
)
|
|
||||||
if action == "cancel":
|
|
||||||
filter_domain = [
|
|
||||||
("state", "=", "cancel"),
|
|
||||||
]
|
|
||||||
trigger_fields = self.env["ir.model.fields"].search(
|
|
||||||
[("model", "=", "pms.reservation"), ("name", "=", "state")]
|
|
||||||
)
|
|
||||||
elif action == "checkin":
|
|
||||||
dict_val = self._get_auto_action_fields_in_checkin_action(moment, time)
|
|
||||||
if moment == "in_act":
|
|
||||||
trigger_fields = self.env["ir.model.fields"].search(
|
|
||||||
[("model", "=", "pms.reservation"), ("name", "=", "state")]
|
|
||||||
)
|
|
||||||
filter_pre_domain = [("state", "=", "confirm")]
|
|
||||||
filter_domain = [
|
|
||||||
("state", "=", "onboard"),
|
|
||||||
]
|
|
||||||
elif action == "checkout":
|
|
||||||
dict_val = self._get_auto_action_fields_in_checkout_action(moment, time)
|
|
||||||
if moment == "in_act":
|
|
||||||
trigger_fields = self.env["ir.model.fields"].search(
|
|
||||||
[("model", "=", "pms.checkin.partner"), ("name", "=", "state")]
|
|
||||||
)
|
|
||||||
filter_pre_domain = [("state", "=", "onboard")]
|
|
||||||
filter_domain = [
|
|
||||||
("state", "=", "done"),
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
filter_domain = [
|
|
||||||
("state", "=", "done"),
|
|
||||||
]
|
|
||||||
elif action == "payment":
|
|
||||||
dict_val = self._get_auto_action_fields_in_payment_action(moment, time)
|
|
||||||
elif action == "invoice":
|
|
||||||
dict_val = self._get_auto_action_fields_in_invoice_action(moment, time)
|
|
||||||
filter_domain = [
|
|
||||||
("folio_ids", "!=", False),
|
|
||||||
]
|
|
||||||
pms_property_ids = self._get_pms_property_ids(properties, is_create)
|
|
||||||
if pms_property_ids:
|
|
||||||
filter_domain.append(("pms_property_id", "in", pms_property_ids))
|
|
||||||
result = {
|
|
||||||
"trigger": dict_val["trigger"],
|
|
||||||
"model_field": dict_val["model_field"],
|
|
||||||
"trigger_fields": trigger_fields,
|
|
||||||
"filter_pre_domain": filter_pre_domain,
|
|
||||||
"filter_domain": filter_domain,
|
|
||||||
"time": dict_val["time"],
|
|
||||||
"model_id": dict_val["model_id"],
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
|
|
||||||
def _get_pms_property_ids(self, properties, is_create):
|
|
||||||
pms_property_ids = []
|
|
||||||
if is_create:
|
|
||||||
pms_property_ids = properties[0][2]
|
|
||||||
else:
|
|
||||||
for pms_property in properties:
|
|
||||||
pms_property_ids.append(pms_property.id)
|
|
||||||
return pms_property_ids
|
|
||||||
|
|||||||
@@ -540,27 +540,38 @@ class PmsFolio(models.Model):
|
|||||||
compute="_compute_document_id",
|
compute="_compute_document_id",
|
||||||
ondelete="restrict",
|
ondelete="restrict",
|
||||||
)
|
)
|
||||||
|
|
||||||
possible_existing_customer_ids = fields.One2many(
|
possible_existing_customer_ids = fields.One2many(
|
||||||
string="Possible existing customer",
|
string="Possible existing customer",
|
||||||
compute="_compute_possible_existing_customer_ids",
|
compute="_compute_possible_existing_customer_ids",
|
||||||
comodel_name="res.partner",
|
comodel_name="res.partner",
|
||||||
inverse_name="folio_possible_customer_id",
|
inverse_name="folio_possible_customer_id",
|
||||||
)
|
)
|
||||||
|
|
||||||
first_checkin = fields.Date(
|
first_checkin = fields.Date(
|
||||||
string="First Folio Checkin",
|
string="First Folio Checkin",
|
||||||
readonly=False,
|
readonly=False,
|
||||||
store=True,
|
store=True,
|
||||||
compute="_compute_first_checkin",
|
compute="_compute_first_checkin",
|
||||||
)
|
)
|
||||||
|
days_to_checkin = fields.Integer(
|
||||||
|
string="Days to Checkin",
|
||||||
|
help="""Technical field to facilitate
|
||||||
|
filtering by dates related to checkin""",
|
||||||
|
compute="_compute_days_to_checkin",
|
||||||
|
search="_search_days_to_checkin",
|
||||||
|
)
|
||||||
last_checkout = fields.Date(
|
last_checkout = fields.Date(
|
||||||
string="Last Folio Checkout",
|
string="Last Folio Checkout",
|
||||||
readonly=False,
|
readonly=False,
|
||||||
store=True,
|
store=True,
|
||||||
compute="_compute_last_checkout",
|
compute="_compute_last_checkout",
|
||||||
)
|
)
|
||||||
|
days_to_checkout = fields.Integer(
|
||||||
|
string="Days to Checkout",
|
||||||
|
help="""Technical field to facilitate
|
||||||
|
filtering by dates related to checkout""",
|
||||||
|
compute="_compute_days_to_checkout",
|
||||||
|
search="_search_days_to_checkout",
|
||||||
|
)
|
||||||
autoinvoice_date = fields.Date(
|
autoinvoice_date = fields.Date(
|
||||||
string="Autoinvoice Date",
|
string="Autoinvoice Date",
|
||||||
compute="_compute_autoinvoice_date",
|
compute="_compute_autoinvoice_date",
|
||||||
@@ -1411,6 +1422,18 @@ class PmsFolio(models.Model):
|
|||||||
checkins = record.reservation_ids.mapped("checkin")
|
checkins = record.reservation_ids.mapped("checkin")
|
||||||
record.first_checkin = min(checkins)
|
record.first_checkin = min(checkins)
|
||||||
|
|
||||||
|
def _compute_days_to_checkin(self):
|
||||||
|
for record in self:
|
||||||
|
record.days_to_checkin = (record.first_checkin - fields.Date.today()).days
|
||||||
|
|
||||||
|
def _search_days_to_checkin(self, operator, value):
|
||||||
|
target_date = fields.Date.today() + timedelta(days=value)
|
||||||
|
if operator in ("=", ">=", ">", "<=", "<"):
|
||||||
|
return [("first_checkin", operator, target_date)]
|
||||||
|
raise UserError(
|
||||||
|
_("Unsupported operator %s for searching on date") % (operator,)
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends("reservation_ids", "reservation_ids.checkout")
|
@api.depends("reservation_ids", "reservation_ids.checkout")
|
||||||
def _compute_last_checkout(self):
|
def _compute_last_checkout(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
@@ -1418,6 +1441,18 @@ class PmsFolio(models.Model):
|
|||||||
checkouts = record.reservation_ids.mapped("checkout")
|
checkouts = record.reservation_ids.mapped("checkout")
|
||||||
record.last_checkout = max(checkouts)
|
record.last_checkout = max(checkouts)
|
||||||
|
|
||||||
|
def _compute_days_to_checkout(self):
|
||||||
|
for record in self:
|
||||||
|
record.days_to_checkout = (record.last_checkout - fields.Date.today()).days
|
||||||
|
|
||||||
|
def _search_days_to_checkout(self, operator, value):
|
||||||
|
target_date = fields.Date.today() + timedelta(days=value)
|
||||||
|
if operator in ("=", ">=", ">", "<=", "<"):
|
||||||
|
return [("last_checkout", operator, target_date)]
|
||||||
|
raise UserError(
|
||||||
|
_("Unsupported operator %s for searching on date") % (operator,)
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends("agency_id")
|
@api.depends("agency_id")
|
||||||
def _compute_invoice_to_agengy(self):
|
def _compute_invoice_to_agengy(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
@@ -1597,94 +1632,26 @@ class PmsFolio(models.Model):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# CHECKIN/OUT PROCESS
|
# MAIL FLOWS
|
||||||
|
|
||||||
def action_open_mail_composer(self):
|
def action_open_confirmation_mail_composer(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
res_id = False
|
||||||
res_ids = []
|
res_ids = []
|
||||||
partner_ids = []
|
partner_ids = []
|
||||||
if all(
|
if self.pms_property_id.property_confirmed_template:
|
||||||
reservation.to_send_mail
|
template = self.pms_property_id.property_confirmed_template
|
||||||
and not reservation.is_modified_reservation
|
else:
|
||||||
and reservation.state in "confirm"
|
raise ValidationError(
|
||||||
for reservation in self.reservation_ids
|
_(
|
||||||
):
|
"You must select a confirmation template "
|
||||||
if self.pms_property_id.property_confirmed_template:
|
"in the email configuration menu of the property"
|
||||||
template = self.pms_property_id.property_confirmed_template
|
|
||||||
else:
|
|
||||||
raise ValidationError(
|
|
||||||
_(
|
|
||||||
"You must select a confirmation template "
|
|
||||||
"in the email configuration menu of the property"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
model = "pms.folio"
|
)
|
||||||
partner_ids = [self.partner_id.id]
|
model = "pms.folio"
|
||||||
res_id = self.id
|
partner_ids = [self.partner_id.id]
|
||||||
composition_mode = "comment"
|
res_id = self.id
|
||||||
elif any(
|
composition_mode = "comment"
|
||||||
reservation.to_send_mail and reservation.is_modified_reservation
|
|
||||||
for reservation in self.reservation_ids
|
|
||||||
) and all(
|
|
||||||
reservation.state not in "cancel" for reservation in self.reservation_ids
|
|
||||||
):
|
|
||||||
if self.pms_property_id.property_modified_template:
|
|
||||||
template = self.pms_property_id.property_modified_template
|
|
||||||
else:
|
|
||||||
raise ValidationError(
|
|
||||||
_(
|
|
||||||
"You must select a modification template "
|
|
||||||
"in the email configuration menu of the property"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
model = "pms.folio"
|
|
||||||
partner_ids = [self.partner_id.id]
|
|
||||||
res_id = self.id
|
|
||||||
composition_mode = "comment"
|
|
||||||
elif any(
|
|
||||||
reservation.to_send_mail and reservation.state in "cancel"
|
|
||||||
for reservation in self.reservation_ids
|
|
||||||
):
|
|
||||||
if self.pms_property_id.property_canceled_template:
|
|
||||||
template = self.pms_property_id.property_canceled_template
|
|
||||||
else:
|
|
||||||
raise ValidationError(
|
|
||||||
_(
|
|
||||||
"You must select a cancelation template "
|
|
||||||
"in the email configuration menu of the property"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
model = "pms.reservation"
|
|
||||||
composition_mode = "mass_mail"
|
|
||||||
for reservation in self.reservation_ids:
|
|
||||||
if reservation.state in "cancel" and reservation.to_send_mail:
|
|
||||||
partner_ids.append(reservation.partner_id.id)
|
|
||||||
res_ids.append(reservation.id)
|
|
||||||
elif any(
|
|
||||||
reservation.to_send_mail and reservation.state in "done"
|
|
||||||
for reservation in self.reservation_ids
|
|
||||||
):
|
|
||||||
if self.pms_property_id.property_exit_template:
|
|
||||||
template = self.pms_property_id.property_exit_template
|
|
||||||
else:
|
|
||||||
raise ValidationError(
|
|
||||||
_(
|
|
||||||
"You must select a exit template in "
|
|
||||||
"the email configuration menu of the property"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
model = "pms.checkin.partner"
|
|
||||||
composition_mode = "mass_mail"
|
|
||||||
for checkin_partner in self.checkin_partner_ids:
|
|
||||||
if (
|
|
||||||
checkin_partner.state == "done"
|
|
||||||
and checkin_partner.reservation_id.to_send_mail
|
|
||||||
):
|
|
||||||
partner_ids.append(checkin_partner.partner_id.id)
|
|
||||||
res_ids.append(checkin_partner.id)
|
|
||||||
compose_form = self.env.ref(
|
|
||||||
"mail.email_compose_message_wizard_form", raise_if_not_found=False
|
|
||||||
)
|
|
||||||
ctx = dict(
|
ctx = dict(
|
||||||
model=model,
|
model=model,
|
||||||
default_model=model,
|
default_model=model,
|
||||||
@@ -1693,6 +1660,103 @@ class PmsFolio(models.Model):
|
|||||||
partner_ids=partner_ids,
|
partner_ids=partner_ids,
|
||||||
force_email=True,
|
force_email=True,
|
||||||
)
|
)
|
||||||
|
return self.action_open_mail_composer(ctx, res_id=res_id, res_ids=res_ids)
|
||||||
|
|
||||||
|
def action_open_modification_mail_composer(self):
|
||||||
|
self.ensure_one()
|
||||||
|
res_id = False
|
||||||
|
res_ids = []
|
||||||
|
partner_ids = []
|
||||||
|
if self.pms_property_id.property_modified_template:
|
||||||
|
template = self.pms_property_id.property_modified_template
|
||||||
|
else:
|
||||||
|
raise ValidationError(
|
||||||
|
_(
|
||||||
|
"You must select a modification template "
|
||||||
|
"in the email configuration menu of the property"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
model = "pms.folio"
|
||||||
|
partner_ids = [self.partner_id.id]
|
||||||
|
res_id = self.id
|
||||||
|
composition_mode = "comment"
|
||||||
|
|
||||||
|
ctx = dict(
|
||||||
|
model=model,
|
||||||
|
default_model=model,
|
||||||
|
default_template_id=template and template.id or False,
|
||||||
|
default_composition_mode=composition_mode,
|
||||||
|
partner_ids=partner_ids,
|
||||||
|
force_email=True,
|
||||||
|
)
|
||||||
|
return self.action_open_mail_composer(ctx, res_id=res_id, res_ids=res_ids)
|
||||||
|
|
||||||
|
def action_open_exit_mail_composer(self):
|
||||||
|
self.ensure_one()
|
||||||
|
res_id = False
|
||||||
|
res_ids = []
|
||||||
|
partner_ids = []
|
||||||
|
|
||||||
|
if self.pms_property_id.property_exit_template:
|
||||||
|
template = self.pms_property_id.property_exit_template
|
||||||
|
else:
|
||||||
|
raise ValidationError(
|
||||||
|
_(
|
||||||
|
"You must select a exit template in "
|
||||||
|
"the email configuration menu of the property"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
model = "pms.checkin.partner"
|
||||||
|
composition_mode = "mass_mail"
|
||||||
|
for checkin_partner in self.checkin_partner_ids:
|
||||||
|
if checkin_partner.state == "done":
|
||||||
|
partner_ids.append(checkin_partner.partner_id.id)
|
||||||
|
res_ids.append(checkin_partner.id)
|
||||||
|
ctx = dict(
|
||||||
|
model=model,
|
||||||
|
default_model=model,
|
||||||
|
default_template_id=template and template.id or False,
|
||||||
|
default_composition_mode=composition_mode,
|
||||||
|
partner_ids=partner_ids,
|
||||||
|
force_email=True,
|
||||||
|
)
|
||||||
|
return self.action_open_mail_composer(ctx, res_id=res_id, res_ids=res_ids)
|
||||||
|
|
||||||
|
def action_open_cancelation_mail_composer(self):
|
||||||
|
self.ensure_one()
|
||||||
|
res_id = False
|
||||||
|
res_ids = []
|
||||||
|
partner_ids = []
|
||||||
|
if self.pms_property_id.property_canceled_template:
|
||||||
|
template = self.pms_property_id.property_canceled_template
|
||||||
|
else:
|
||||||
|
raise ValidationError(
|
||||||
|
_(
|
||||||
|
"You must select a cancelation template "
|
||||||
|
"in the email configuration menu of the property"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
model = "pms.reservation"
|
||||||
|
composition_mode = "mass_mail"
|
||||||
|
for reservation in self.reservation_ids:
|
||||||
|
if reservation.state == "cancel":
|
||||||
|
partner_ids.append(reservation.partner_id.id)
|
||||||
|
res_ids.append(reservation.id)
|
||||||
|
ctx = dict(
|
||||||
|
model=model,
|
||||||
|
default_model=model,
|
||||||
|
default_template_id=template and template.id or False,
|
||||||
|
default_composition_mode=composition_mode,
|
||||||
|
partner_ids=partner_ids,
|
||||||
|
force_email=True,
|
||||||
|
)
|
||||||
|
return self.action_open_mail_composer(ctx, res_id=res_id, res_ids=res_ids)
|
||||||
|
|
||||||
|
def action_open_mail_composer(self, ctx, res_id=False, res_ids=False):
|
||||||
|
compose_form = self.env.ref(
|
||||||
|
"mail.email_compose_message_wizard_form", raise_if_not_found=False
|
||||||
|
)
|
||||||
|
composition_mode = ctx.get("default_composition_mode")
|
||||||
if composition_mode == "comment":
|
if composition_mode == "comment":
|
||||||
ctx.update(
|
ctx.update(
|
||||||
default_res_id=res_id,
|
default_res_id=res_id,
|
||||||
|
|||||||
@@ -195,7 +195,6 @@ class PmsProperty(models.Model):
|
|||||||
copy=False,
|
copy=False,
|
||||||
comodel_name="res.users",
|
comodel_name="res.users",
|
||||||
ondelete="restrict",
|
ondelete="restrict",
|
||||||
tracking=True,
|
|
||||||
)
|
)
|
||||||
member_ids = fields.One2many(
|
member_ids = fields.One2many(
|
||||||
string="Team Members",
|
string="Team Members",
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ class PmsReservation(models.Model):
|
|||||||
tax_ids = fields.Many2many(
|
tax_ids = fields.Many2many(
|
||||||
string="Taxes",
|
string="Taxes",
|
||||||
help="Taxes applied in the reservation",
|
help="Taxes applied in the reservation",
|
||||||
readonly="False",
|
readonly=False,
|
||||||
store=True,
|
store=True,
|
||||||
compute="_compute_tax_ids",
|
compute="_compute_tax_ids",
|
||||||
comodel_name="account.tax",
|
comodel_name="account.tax",
|
||||||
@@ -656,20 +656,43 @@ class PmsReservation(models.Model):
|
|||||||
comodel_name="res.partner",
|
comodel_name="res.partner",
|
||||||
inverse_name="reservation_possible_customer_id",
|
inverse_name="reservation_possible_customer_id",
|
||||||
)
|
)
|
||||||
to_send_mail = fields.Boolean(
|
|
||||||
string="To Send Mail",
|
avoid_mails = fields.Boolean(
|
||||||
compute="_compute_to_send_mail",
|
string="Avoid comunication mails",
|
||||||
|
help="Field to indicate not sent mail comunications",
|
||||||
|
compute="_compute_avoid_mails",
|
||||||
readonly=False,
|
readonly=False,
|
||||||
store=True,
|
store=True,
|
||||||
default=False,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
is_modified_reservation = fields.Boolean(
|
to_send_confirmation_mail = fields.Boolean(
|
||||||
string="Is A Modified Reservation",
|
string="To Send Confirmation Mail",
|
||||||
compute="_compute_is_modified_reservation",
|
compute="_compute_to_send_confirmation_mail",
|
||||||
readonly=False,
|
readonly=False,
|
||||||
store=True,
|
store=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
to_send_modification_mail = fields.Boolean(
|
||||||
|
string="To Send Modification Mail",
|
||||||
|
compute="_compute_to_send_modification_mail",
|
||||||
|
readonly=False,
|
||||||
|
store=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
to_send_exit_mail = fields.Boolean(
|
||||||
|
string="To Send Exit Mail",
|
||||||
|
compute="_compute_to_send_exit_mail",
|
||||||
|
readonly=False,
|
||||||
|
store=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
to_send_cancelation_mail = fields.Boolean(
|
||||||
|
string="To Send Cancelation Mail",
|
||||||
|
compute="_compute_to_send_cancelation_mail",
|
||||||
|
readonly=False,
|
||||||
|
store=True,
|
||||||
|
)
|
||||||
|
|
||||||
overnight_room = fields.Boolean(
|
overnight_room = fields.Boolean(
|
||||||
related="room_type_id.overnight_room",
|
related="room_type_id.overnight_room",
|
||||||
store=True,
|
store=True,
|
||||||
@@ -1529,20 +1552,53 @@ class PmsReservation(models.Model):
|
|||||||
else:
|
else:
|
||||||
record.possible_existing_customer_ids = False
|
record.possible_existing_customer_ids = False
|
||||||
|
|
||||||
@api.depends("checkin", "checkout")
|
@api.depends("reservation_type")
|
||||||
def _compute_is_modified_reservation(self):
|
def _compute_avoid_mails(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.state in "draft":
|
if record.reservation_type == "out":
|
||||||
record.is_modified_reservation = False
|
record.avoid_mails = True
|
||||||
elif (
|
elif not record.avoid_mails:
|
||||||
record._origin.checkin != record.checkin
|
record.avoid_mails = False
|
||||||
or record._origin.checkout != record.checkout
|
|
||||||
) and not record.to_send_mail:
|
@api.depends("reservation_type", "state")
|
||||||
record.is_modified_reservation = True
|
def _compute_to_send_confirmation_mail(self):
|
||||||
for reservations in record.folio_id.reservation_ids:
|
for record in self:
|
||||||
reservations.to_send_mail = True
|
if record.state in ("confirm") and not record.avoid_mails:
|
||||||
|
record.to_send_confirmation_mail = True
|
||||||
else:
|
else:
|
||||||
record.is_modified_reservation = False
|
record.to_send_confirmation_mail = False
|
||||||
|
|
||||||
|
@api.depends("checkin", "checkout")
|
||||||
|
def _compute_to_send_modification_mail(self):
|
||||||
|
for record in self:
|
||||||
|
if (
|
||||||
|
record.state == "confirm"
|
||||||
|
and not record.to_send_confirmation_mail
|
||||||
|
and not record.avoid_mails
|
||||||
|
and (
|
||||||
|
record._origin.checkin != record.checkin
|
||||||
|
or record._origin.checkout != record.checkout
|
||||||
|
)
|
||||||
|
):
|
||||||
|
record.to_send_modification_mail = True
|
||||||
|
else:
|
||||||
|
record.to_send_modification_mail = False
|
||||||
|
|
||||||
|
@api.depends("reservation_type", "state")
|
||||||
|
def _compute_to_send_exit_mail(self):
|
||||||
|
for record in self:
|
||||||
|
if record.state in ("done") and not record.avoid_mails:
|
||||||
|
record.to_send_exit_mail = True
|
||||||
|
else:
|
||||||
|
record.to_send_exit_mail = False
|
||||||
|
|
||||||
|
@api.depends("reservation_type", "state")
|
||||||
|
def _compute_to_send_cancelation_mail(self):
|
||||||
|
for record in self:
|
||||||
|
if record.state in ("cancel") and not record.avoid_mails:
|
||||||
|
record.to_send_cancelation_mail = True
|
||||||
|
else:
|
||||||
|
record.to_send_cancelation_mail = False
|
||||||
|
|
||||||
@api.depends("partner_id")
|
@api.depends("partner_id")
|
||||||
def _compute_lang(self):
|
def _compute_lang(self):
|
||||||
@@ -1552,14 +1608,6 @@ class PmsReservation(models.Model):
|
|||||||
else:
|
else:
|
||||||
record.lang = self.env["res.lang"].get_installed()
|
record.lang = self.env["res.lang"].get_installed()
|
||||||
|
|
||||||
@api.depends("reservation_type", "state")
|
|
||||||
def _compute_to_send_mail(self):
|
|
||||||
for record in self:
|
|
||||||
if record.state in ("confirm", "done", "cancel"):
|
|
||||||
record.to_send_mail = True
|
|
||||||
if record.reservation_type == "out":
|
|
||||||
record.to_send_mail = False
|
|
||||||
|
|
||||||
def _search_allowed_checkin(self, operator, value):
|
def _search_allowed_checkin(self, operator, value):
|
||||||
if operator not in ("=",):
|
if operator not in ("=",):
|
||||||
raise UserError(
|
raise UserError(
|
||||||
@@ -1832,8 +1880,17 @@ class PmsReservation(models.Model):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def action_open_mail_composer(self):
|
def action_open_confirmation_mail_composer(self):
|
||||||
return self.folio_id.action_open_mail_composer()
|
return self.folio_id.action_open_confirmation_mail_composer()
|
||||||
|
|
||||||
|
def action_open_modification_mail_composer(self):
|
||||||
|
return self.folio_id.action_open_modification_mail_composer()
|
||||||
|
|
||||||
|
def action_open_exit_mail_composer(self):
|
||||||
|
return self.folio_id.action_open_exit_mail_composer()
|
||||||
|
|
||||||
|
def action_open_cancelation_mail_composer(self):
|
||||||
|
return self.folio_id.action_open_cancelation_mail_composer()
|
||||||
|
|
||||||
def open_wizard_several_partners(self):
|
def open_wizard_several_partners(self):
|
||||||
ctx = dict(
|
ctx = dict(
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
# Copyright 2017 Alexandre Díaz
|
# Copyright 2017 Alexandre Díaz
|
||||||
# Copyright 2017 Dario Lodeiros
|
# Copyright 2017 Dario Lodeiros
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
import logging
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class PmsService(models.Model):
|
class PmsService(models.Model):
|
||||||
_name = "pms.service"
|
_name = "pms.service"
|
||||||
@@ -298,8 +296,7 @@ class PmsService(models.Model):
|
|||||||
service.name = name
|
service.name = name
|
||||||
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
"reservation_id.checkin",
|
"reservation_id.reservation_line_ids",
|
||||||
"reservation_id.checkout",
|
|
||||||
"product_id",
|
"product_id",
|
||||||
"reservation_id.adults",
|
"reservation_id.adults",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
# Copyright 2017 Dario Lodeiros
|
# Copyright 2017 Dario Lodeiros
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
import datetime
|
import datetime
|
||||||
|
import logging
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class PmsServiceLine(models.Model):
|
class PmsServiceLine(models.Model):
|
||||||
_name = "pms.service.line"
|
_name = "pms.service.line"
|
||||||
|
|||||||
@@ -38,4 +38,5 @@ from . import test_pms_wizard_split_join_swap_reservation
|
|||||||
from . import test_product_template
|
from . import test_product_template
|
||||||
from . import test_pms_multiproperty
|
from . import test_pms_multiproperty
|
||||||
from . import test_shared_room
|
from . import test_shared_room
|
||||||
from . import test_automated_mails
|
|
||||||
|
# from . import test_automated_mails
|
||||||
|
|||||||
@@ -3577,38 +3577,38 @@ class TestPmsReservations(TestPms):
|
|||||||
# "is_modified_reservation field should be True ",
|
# "is_modified_reservation field should be True ",
|
||||||
# )
|
# )
|
||||||
|
|
||||||
@freeze_time("2012-01-14")
|
# @freeze_time("2012-01-14")
|
||||||
def test_is_not_modified_reservation(self):
|
# def test_is_not_modified_reservation(self):
|
||||||
"""
|
# """
|
||||||
Checked that the is_modified_reservation field is correctly set
|
# Checked that the is_modified_reservation field is correctly set
|
||||||
to False when the reservation is modified but not the checkin
|
# to False when the reservation is modified but not the checkin
|
||||||
or checkout fields.
|
# or checkout fields.
|
||||||
----------------------
|
# ----------------------
|
||||||
A reservation is created. The adults, arrival_hour and departure_hours
|
# A reservation is created. The adults, arrival_hour and departure_hours
|
||||||
fields of the reservation are modified.The it is verified that the state
|
# fields of the reservation are modified.The it is verified that the state
|
||||||
of this field is False.
|
# of this field is False.
|
||||||
"""
|
# """
|
||||||
# ARRANGE
|
# # ARRANGE
|
||||||
checkin = fields.date.today()
|
# checkin = fields.date.today()
|
||||||
checkout = fields.date.today() + datetime.timedelta(days=2)
|
# checkout = fields.date.today() + datetime.timedelta(days=2)
|
||||||
reservation_vals = {
|
# reservation_vals = {
|
||||||
"checkin": checkin,
|
# "checkin": checkin,
|
||||||
"checkout": checkout,
|
# "checkout": checkout,
|
||||||
"room_type_id": self.room_type_double.id,
|
# "room_type_id": self.room_type_double.id,
|
||||||
"partner_id": self.partner1.id,
|
# "partner_id": self.partner1.id,
|
||||||
"pms_property_id": self.pms_property1.id,
|
# "pms_property_id": self.pms_property1.id,
|
||||||
}
|
# }
|
||||||
|
|
||||||
reservation = self.env["pms.reservation"].create(reservation_vals)
|
# reservation = self.env["pms.reservation"].create(reservation_vals)
|
||||||
reservation.update(
|
# reservation.update(
|
||||||
{"adults": 1, "arrival_hour": "18:00", "departure_hour": "08:00"}
|
# {"adults": 1, "arrival_hour": "18:00", "departure_hour": "08:00"}
|
||||||
)
|
# )
|
||||||
|
|
||||||
# ASSERT
|
# # ASSERT
|
||||||
self.assertFalse(
|
# self.assertFalse(
|
||||||
reservation.is_modified_reservation,
|
# reservation.is_modified_reservation,
|
||||||
"is_modified_reservation field should be False ",
|
# "is_modified_reservation field should be False ",
|
||||||
)
|
# )
|
||||||
|
|
||||||
@freeze_time("2012-01-14")
|
@freeze_time("2012-01-14")
|
||||||
def test_not_add_several_possibles_customers(self):
|
def test_not_add_several_possibles_customers(self):
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<odoo>
|
|
||||||
<record model="ir.ui.view" id="pms_automated_mails_view">
|
|
||||||
<field name="name">pms.automated_mails_view_form</field>
|
|
||||||
<field name="model">pms.automated.mails</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<form string="Automated Mails" class="pt-1">
|
|
||||||
<sheet>
|
|
||||||
<div class="col-5">
|
|
||||||
<label for="name" />
|
|
||||||
<group>
|
|
||||||
<h2><field name="name" /></h2>
|
|
||||||
</group>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-5">
|
|
||||||
<group>
|
|
||||||
<field name="active" widget="boolean_toggle" />
|
|
||||||
<field name="template_id" />
|
|
||||||
<field name="action" />
|
|
||||||
<field
|
|
||||||
name="pms_property_ids"
|
|
||||||
widget="many2many_tags"
|
|
||||||
options="{'no_create': True,'no_open': True}"
|
|
||||||
/>
|
|
||||||
</group>
|
|
||||||
</div>
|
|
||||||
<div class="col-5">
|
|
||||||
<group>
|
|
||||||
<field name="moment" />
|
|
||||||
<field
|
|
||||||
name="time"
|
|
||||||
attrs="{'invisible':[('moment','=','in_act')]}"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="time_type"
|
|
||||||
attrs="{'invisible':[('moment','=','in_act')]}"
|
|
||||||
/>
|
|
||||||
</group>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</sheet>
|
|
||||||
</form>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
<record id="view_automated_mails_tree" model="ir.ui.view">
|
|
||||||
<field name="name">pms.automated.mails.tree</field>
|
|
||||||
<field name="model">pms.automated.mails</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<tree string="Automated Mails">
|
|
||||||
<field name="name" />
|
|
||||||
<field name="action" />
|
|
||||||
<field name="template_id" />
|
|
||||||
<field name="moment" />
|
|
||||||
<field name="time" />
|
|
||||||
<field name="time_type" />
|
|
||||||
</tree>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
<record model="ir.actions.act_window" id="open_pms_automated_mails_tree">
|
|
||||||
<field name="name">Automated Mails</field>
|
|
||||||
<field name="res_model">pms.automated.mails</field>
|
|
||||||
<field name="view_id" ref="view_automated_mails_tree" />
|
|
||||||
<field name="view_mode">tree,form</field>
|
|
||||||
</record>
|
|
||||||
<menuitem
|
|
||||||
name="Automated Mails"
|
|
||||||
id="menu_pms_automated_mails"
|
|
||||||
action="open_pms_automated_mails_tree"
|
|
||||||
sequence="40"
|
|
||||||
parent="pms.pms_configuration_menu"
|
|
||||||
/>
|
|
||||||
</odoo>
|
|
||||||
@@ -281,6 +281,8 @@
|
|||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<group string="General Info" name="contact_details">
|
<group string="General Info" name="contact_details">
|
||||||
|
<field name="days_to_checkin" />
|
||||||
|
<field name="days_to_checkout" />
|
||||||
<field
|
<field
|
||||||
name="document_type"
|
name="document_type"
|
||||||
attrs="{'invisible':[('reservation_type','in',('out'))]}"
|
attrs="{'invisible':[('reservation_type','in',('out'))]}"
|
||||||
|
|||||||
@@ -44,32 +44,35 @@
|
|||||||
type="object"
|
type="object"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
name="action_open_mail_composer"
|
name="action_open_confirmation_mail_composer"
|
||||||
string="Send Confirmation Email "
|
string="Send Confirmation Email "
|
||||||
type="object"
|
type="object"
|
||||||
attrs="{'invisible':['|','|','|',('to_send_mail', '=', False),('is_modified_reservation', '=', True),('state', 'not in', 'confirm'),('reservation_type', 'in', 'out')]}"
|
attrs="{'invisible':[('to_send_confirmation_mail', '=', False)]}"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
name="action_open_mail_composer"
|
name="action_open_modification_mail_composer"
|
||||||
string="Send Modification Email "
|
string="Send Modification Email "
|
||||||
type="object"
|
type="object"
|
||||||
attrs="{'invisible':['|','|','|',('to_send_mail', '=', False), ('is_modified_reservation', '=', False), ('state', 'in', 'cancel'),('reservation_type', 'in', 'out')]}"
|
attrs="{'invisible':[('to_send_modification_mail', '=', False)]}"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
name="action_open_mail_composer"
|
name="action_open_exit_mail_composer"
|
||||||
string="Send Exit Email "
|
string="Send Exit Email "
|
||||||
type="object"
|
type="object"
|
||||||
attrs="{'invisible':['|','|',('to_send_mail', '=', False), ('state', 'not in', 'done'),('reservation_type', 'in', 'out')]}"
|
attrs="{'invisible':[('to_send_exit_mail', '=', False)]}"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
name="action_open_mail_composer"
|
name="action_open_cancelation_mail_composer"
|
||||||
string="Send Cancellation Email "
|
string="Send Cancellation Email "
|
||||||
type="object"
|
type="object"
|
||||||
attrs="{'invisible':['|','|',('to_send_mail', '=', False), ('state', 'not in', 'cancel'),('reservation_type', 'in', 'out')]}"
|
attrs="{'invisible':[('to_send_cancelation_mail', '=', False)]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<field name="state" widget="statusbar" />
|
<field name="state" widget="statusbar" />
|
||||||
<field name="to_send_mail" invisible="1" />
|
<field name="to_send_confirmation_mail" invisible="1" />
|
||||||
<field name="is_modified_reservation" invisible="1" />
|
<field name="to_send_modification_mail" invisible="1" />
|
||||||
|
<field name="to_send_exit_mail" invisible="1" />
|
||||||
|
<field name="to_send_cancelation_mail" invisible="1" />
|
||||||
</header>
|
</header>
|
||||||
<div
|
<div
|
||||||
class="alert alert-info"
|
class="alert alert-info"
|
||||||
@@ -567,7 +570,11 @@
|
|||||||
<field name="price_tax" optional="hide" />
|
<field name="price_tax" optional="hide" />
|
||||||
<field name="discount" />
|
<field name="discount" />
|
||||||
<field name="price_total" />
|
<field name="price_total" />
|
||||||
<field name="service_line_ids" invisible="1">
|
<field
|
||||||
|
name="service_line_ids"
|
||||||
|
invisible="1"
|
||||||
|
readonly="1"
|
||||||
|
>
|
||||||
<tree string="Days">
|
<tree string="Days">
|
||||||
<field name="date" />
|
<field name="date" />
|
||||||
<field name="day_qty" />
|
<field name="day_qty" />
|
||||||
|
|||||||
Reference in New Issue
Block a user