diff --git a/pms_l10n_es/models/pms_tourist_room.py b/pms_l10n_es/models/pms_tourist_room.py index d112affb50..6d2e12e2b7 100644 --- a/pms_l10n_es/models/pms_tourist_room.py +++ b/pms_l10n_es/models/pms_tourist_room.py @@ -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): @@ -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)