From 8aabb130f8223c9958bebbf8ede7914a0bd2aa4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Lodeiros?= Date: Sun, 5 Feb 2023 16:57:33 +0100 Subject: [PATCH] [IMP]pms: improvement control in blocked reservation lines changes --- pms/models/pms_reservation_line.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/pms/models/pms_reservation_line.py b/pms/models/pms_reservation_line.py index a6bfd2d59..a2bef0ef4 100644 --- a/pms/models/pms_reservation_line.py +++ b/pms/models/pms_reservation_line.py @@ -506,10 +506,27 @@ class PmsReservationLine(models.Model): record.default_invoice_to = False def write(self, vals): - if ( - any([record.reservation_id.blocked for record in self]) - and not self.env.context.get("force_write_blocked") - and ("date" in vals or "price" in vals) + if not self.env.context.get("force_write_blocked") and ( + ( + "price" in vals + and any( + [ + vals["date"] != record.date + for record in self + if record.reservation_id.blocked + ] + ) + ) + or ( + "price" in vals + and any( + [ + round(vals["price"], 2) != round(record.price, 2) + for record in self + if record.reservation_id.blocked + ] + ) + ) ): raise ValidationError(_("Blocked reservations can't be modified")) res = super().write(vals)