mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] pms: delete compute of sale_channel_origin through agency_id
This commit is contained in:
committed by
Darío Lodeiros
parent
f98a467749
commit
72d502aee7
@@ -226,8 +226,6 @@ class PmsFolio(models.Model):
|
||||
string="Sale Channel Origin",
|
||||
help="Sale Channel through which folio was created, the original",
|
||||
comodel_name="pms.sale.channel",
|
||||
store=True,
|
||||
compute="_compute_sale_channel_origin_id",
|
||||
)
|
||||
|
||||
transaction_ids = fields.Many2many(
|
||||
@@ -1063,12 +1061,6 @@ class PmsFolio(models.Model):
|
||||
if reservation.commission_amount != 0:
|
||||
folio.commission = folio.commission + reservation.commission_amount
|
||||
|
||||
@api.depends("agency_id")
|
||||
def _compute_sale_channel_origin_id(self):
|
||||
for folio in self:
|
||||
if folio.agency_id:
|
||||
folio.sale_channel_origin_id = folio.agency_id.sale_channel_id.id
|
||||
|
||||
@api.depends("reservation_ids", "reservation_ids.sale_channel_ids")
|
||||
def _compute_sale_channel_ids(self):
|
||||
for record in self:
|
||||
|
||||
@@ -1891,6 +1891,7 @@ class PmsReservation(models.Model):
|
||||
"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"""
|
||||
@@ -2026,7 +2027,7 @@ class PmsReservation(models.Model):
|
||||
vals.update(default_vals)
|
||||
elif (
|
||||
"pms_property_id" in vals
|
||||
and ("sale_channel_origin_id" in vals or "agency_id" in vals)
|
||||
and "sale_channel_origin_id" in vals
|
||||
and ("partner_name" in vals or "partner_id" in vals or "agency_id" in vals)
|
||||
):
|
||||
folio_vals = {
|
||||
|
||||
@@ -1895,7 +1895,7 @@ class TestPmsReservations(TestPms):
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=152),
|
||||
"agency_id": agency.id,
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"sale_channel_origin_id": self.sale_channel_direct.id
|
||||
"sale_channel_origin_id": self.sale_channel_direct.id,
|
||||
}
|
||||
)
|
||||
self.assertEqual(
|
||||
@@ -2611,7 +2611,7 @@ class TestPmsReservations(TestPms):
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=152),
|
||||
"agency_id": agency.id,
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"sale_channel_origin_id": self.sale_channel_direct.id
|
||||
"sale_channel_origin_id": self.sale_channel_direct.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3779,7 +3779,7 @@ class TestPmsReservations(TestPms):
|
||||
"pms_property_id": self.pms_property1.id,
|
||||
"agency_id": self.agency1.id,
|
||||
"service_ids": [self.service.id],
|
||||
"sale_channel_origin_id": self.sale_channel_direct.id
|
||||
"sale_channel_origin_id": self.sale_channel_direct.id,
|
||||
}
|
||||
# ACT
|
||||
reservation = self.env["pms.reservation"].create(reservation_vals)
|
||||
@@ -4239,7 +4239,9 @@ class TestPmsReservations(TestPms):
|
||||
with self.assertRaises(
|
||||
ValidationError,
|
||||
msg="Error, there cannot be a reservation in which at least one of its reservation"
|
||||
"lines doesn't have as sale_channel_id the sale_channel_origin_id of reservation",
|
||||
"lines doesn't have as sale_channel_id the sale_channel_origin_id of reservation",
|
||||
):
|
||||
reservation1.reservation_line_ids.write({"sale_channel_id": sale_channel_phone})
|
||||
reservation1.reservation_line_ids.write(
|
||||
{"sale_channel_id": sale_channel_phone}
|
||||
)
|
||||
reservation1.flush()
|
||||
|
||||
@@ -56,6 +56,7 @@ class TestPmsSaleChannel(TestPms):
|
||||
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
|
||||
"agency_id": agency1.id,
|
||||
"pms_property_id": self.pms_property1.id,
|
||||
"sale_channel_origin_id": sale_channel1.id,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user