diff --git a/pms/models/pms_folio.py b/pms/models/pms_folio.py index 6942a834fa..ebbfaeaab3 100644 --- a/pms/models/pms_folio.py +++ b/pms/models/pms_folio.py @@ -882,14 +882,16 @@ def _compute_company_id(self): ) def _compute_pricelist_id(self): for folio in self: + is_new = not folio.pricelist_id or not isinstance(folio.id, models.NewId) if folio.reservation_type in ("out", "staff"): folio.pricelist_id = False elif len(folio.reservation_ids.pricelist_id) == 1: folio.pricelist_id = folio.reservation_ids.pricelist_id - elif folio.agency_id and folio.agency_id.apply_pricelist: + elif folio.agency_id and folio.agency_id.apply_pricelist and is_new: folio.pricelist_id = folio.agency_id.property_product_pricelist elif ( - folio.partner_id + is_new + and folio.partner_id and folio.partner_id.property_product_pricelist and folio.partner_id.property_product_pricelist.is_pms_available ): diff --git a/pms/models/pms_reservation.py b/pms/models/pms_reservation.py index a07baf15af..6dc1f15bd0 100644 --- a/pms/models/pms_reservation.py +++ b/pms/models/pms_reservation.py @@ -1018,22 +1018,26 @@ def _compute_service_ids(self): @api.depends("partner_id", "agency_id") def _compute_pricelist_id(self): for reservation in self: + is_new = not reservation.pricelist_id or not isinstance( + reservation.id, models.NewId + ) if reservation.reservation_type in ("out", "staff"): reservation.pricelist_id = False - elif reservation.agency_id and reservation.agency_id.apply_pricelist: + elif ( + is_new + and reservation.agency_id + and reservation.agency_id.apply_pricelist + ): reservation.pricelist_id = ( reservation.agency_id.property_product_pricelist ) # only change de pricelist if the reservation is not yet saved # and the partner has a pricelist default elif ( - reservation.partner_id + is_new + and reservation.partner_id and reservation.partner_id.property_product_pricelist and reservation.partner_id.property_product_pricelist.is_pms_available - and ( - not reservation.pricelist_id - or not isinstance(reservation.id, models.NewId) - ) ): reservation.pricelist_id = ( reservation.partner_id.property_product_pricelist