Skip to content

Commit

Permalink
[FIX] pms_tourism_room: fix calculation of tourist room in the proper…
Browse files Browse the repository at this point in the history
…ty information card
  • Loading branch information
IrluiDev committed Jul 31, 2024
1 parent 3340d8f commit 018a01e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pms_l10n_es/models/pms_tourist_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ class PmsProperty(models.Model):

@api.depends("room_ids")
def _compute_total_rooms(self):
target_rooms = self.env["pms.room"].search([("pms_property_id", "=", self.id)])
self.total_tourist_rooms = len(target_rooms)
return self.total_tourist_rooms
for record in self:
target_rooms = self.env["pms.room"].search(
[("pms_property_id", "=", record.id)]
)
record.total_tourist_rooms = len(target_rooms)

@api.constrains("total_tourist_rooms")
def _check_total_tourism_rooms(self):
Expand All @@ -33,10 +35,5 @@ def _check_total_tourism_rooms(self):
)
)

@api.model
def _get_default_total_rooms(self):
target_rooms = self.env["pms.room"].search([("pms_property_id", "=", self.id)])
if target_rooms:
self.total_tourist_rooms = len(target_rooms)
return self.total_tourist_rooms
return 0
return len(self.room_ids)

0 comments on commit 018a01e

Please sign in to comment.