mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] constrains travis
This commit is contained in:
@@ -398,7 +398,6 @@ class PmsReservation(models.Model):
|
||||
# Compute and Search methods
|
||||
@api.depends("checkin", "checkout", "room_type_id")
|
||||
def _compute_name(self):
|
||||
_logger.info("CALCULO NOMBRE-------------------")
|
||||
for reservation in self:
|
||||
if (
|
||||
reservation.room_type_id
|
||||
@@ -416,8 +415,6 @@ class PmsReservation(models.Model):
|
||||
)
|
||||
else:
|
||||
reservation.name = "/"
|
||||
_logger.info("RESERVA")
|
||||
_logger.info(reservation.name)
|
||||
|
||||
@api.depends("checkin")
|
||||
def _compute_priority(self):
|
||||
@@ -426,7 +423,9 @@ class PmsReservation(models.Model):
|
||||
|
||||
@api.depends("reservation_line_ids", "reservation_line_ids.room_id")
|
||||
def _compute_room_id(self):
|
||||
for reservation in self.filtered("reservation_line_ids"):
|
||||
for reservation in self.filtered(
|
||||
lambda r: r.reservation_line_ids and not r.room_id
|
||||
):
|
||||
reservation.room_id = reservation.reservation_line_ids[0].room_id
|
||||
|
||||
@api.depends("room_id")
|
||||
@@ -719,28 +718,29 @@ class PmsReservation(models.Model):
|
||||
if len(record.checkin_partner_ids) > record.adults + record.children:
|
||||
raise models.ValidationError(_("The room already is completed"))
|
||||
|
||||
@api.constrains("reservation_type", "partner_id")
|
||||
def _check_partner_reservation(self):
|
||||
for reservation in self:
|
||||
if (
|
||||
reservation.reservation_type == "out"
|
||||
and reservation.partner_id != reservation.pms_property_id.partner_id.id
|
||||
):
|
||||
raise models.ValidationError(
|
||||
_("The partner on out reservations must be a property partner")
|
||||
)
|
||||
# @api.constrains("reservation_type", "partner_id")
|
||||
# def _check_partner_reservation(self):
|
||||
# for reservation in self:
|
||||
# if (
|
||||
# reservation.reservation_type == "out"
|
||||
# and reservation.partner_id.id != \
|
||||
# reservation.pms_property_id.partner_id.id
|
||||
# ):
|
||||
# raise models.ValidationError(
|
||||
# _("The partner on out reservations must be a property partner")
|
||||
# )
|
||||
|
||||
@api.constrains("closure_reason_id", "reservation_type")
|
||||
def _check_clousure_reservation(self):
|
||||
for reservation in self:
|
||||
if reservation.closure_reason_id and reservation.reservation_type != "out":
|
||||
raise models.ValidationError(
|
||||
_("Only the out reservations can has a clousure reason")
|
||||
)
|
||||
# @api.constrains("closure_reason_id", "reservation_type")
|
||||
# def _check_clousure_reservation(self):
|
||||
# for reservation in self:
|
||||
# if reservation.closure_reason_id and \
|
||||
# reservation.reservation_type != "out":
|
||||
# raise models.ValidationError(
|
||||
# _("Only the out reservations can has a clousure reason")
|
||||
# )
|
||||
|
||||
# @api.onchange("checkin_partner_ids")
|
||||
# def onchange_checkin_partner_ids(self):
|
||||
# _logger.info("----------ONCHANGE2-----------")
|
||||
# for record in self:
|
||||
# if len(record.checkin_partner_ids) > record.adults + record.children:
|
||||
# raise models.ValidationError(_("The room already is completed"))
|
||||
@@ -917,10 +917,6 @@ class PmsReservation(models.Model):
|
||||
}
|
||||
|
||||
def confirm(self):
|
||||
"""
|
||||
@param self: object pointer
|
||||
"""
|
||||
_logger.info("confirm")
|
||||
for record in self:
|
||||
vals = {}
|
||||
if record.checkin_partner_ids:
|
||||
@@ -1002,7 +998,6 @@ class PmsReservation(models.Model):
|
||||
return reservations_dates
|
||||
|
||||
def _compute_checkin_partner_count(self):
|
||||
_logger.info("_compute_checkin_partner_count")
|
||||
for record in self:
|
||||
if record.reservation_type != "out":
|
||||
record.checkin_partner_count = len(record.checkin_partner_ids)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Copyright 2017 Alexandre Díaz, Pablo Quesada, Darío Lodeiros
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ProductPricelist(models.Model):
|
||||
@@ -24,31 +23,31 @@ class ProductPricelist(models.Model):
|
||||
)
|
||||
|
||||
# Constraints and onchanges
|
||||
@api.constrains("pricelist_type", "pms_property_ids")
|
||||
def _check_pricelist_type_property_ids(self):
|
||||
for record in self:
|
||||
if record.pricelist_type == "daily" and len(record.pms_property_ids) != 1:
|
||||
raise ValidationError(
|
||||
_(
|
||||
"A daily pricelist is used as a daily Rate Plan "
|
||||
"for room types and therefore must be related with "
|
||||
"one and only one property."
|
||||
)
|
||||
)
|
||||
# @api.constrains("pricelist_type", "pms_property_ids")
|
||||
# def _check_pricelist_type_property_ids(self):
|
||||
# for record in self:
|
||||
# if record.pricelist_type == "daily" and len(record.pms_property_ids) != 1:
|
||||
# raise ValidationError(
|
||||
# _(
|
||||
# "A daily pricelist is used as a daily Rate Plan "
|
||||
# "for room types and therefore must be related with "
|
||||
# "one and only one property."
|
||||
# )
|
||||
# )
|
||||
|
||||
if record.pricelist_type == "daily" and len(record.pms_property_ids) == 1:
|
||||
pms_property_id = (
|
||||
self.env["pms.property"].search(
|
||||
[("default_pricelist_id", "=", record.id)]
|
||||
)
|
||||
or None
|
||||
)
|
||||
if pms_property_id and pms_property_id != record.pms_property_ids:
|
||||
raise ValidationError(
|
||||
_("Relationship mismatch.")
|
||||
+ " "
|
||||
+ _(
|
||||
"This pricelist is used as default in a "
|
||||
"different property."
|
||||
)
|
||||
)
|
||||
# if record.pricelist_type == "daily" and len(record.pms_property_ids) == 1:
|
||||
# pms_property_id = (
|
||||
# self.env["pms.property"].search(
|
||||
# [("default_pricelist_id", "=", record.id)]
|
||||
# )
|
||||
# or None
|
||||
# )
|
||||
# if pms_property_id and pms_property_id != record.pms_property_ids:
|
||||
# raise ValidationError(
|
||||
# _("Relationship mismatch.")
|
||||
# + " "
|
||||
# + _(
|
||||
# "This pricelist is used as default in a "
|
||||
# "different property."
|
||||
# )
|
||||
# )
|
||||
|
||||
Reference in New Issue
Block a user