[IMP] pms: restrict that reservation_lines haven't sale channels other than sales origin of reservation

This commit is contained in:
Sara Lago
2022-03-25 10:32:47 +01:00
committed by Darío Lodeiros
parent cc03cc2d67
commit f98a467749
2 changed files with 47 additions and 0 deletions

View File

@@ -1879,6 +1879,18 @@ class PmsReservation(models.Model):
)
)
@api.constrains("sale_channel_ids")
def _check_lines_with_sale_channel_id(self):
for record in self:
if record.reservation_line_ids:
if record.sale_channel_origin_id not in record.sale_channel_ids:
raise ValidationError(
_(
"Reservation must have one reservation line "
"with sale channel equal to sale channel origin of reservation."
"Change sale_channel_origin of reservation before"
)
)
# Action methods
def open_partner(self):
"""Utility method used to add an "View Customer" button in reservation views"""