mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[UPD] store computed fields
This commit is contained in:
@@ -44,7 +44,7 @@ class HotelRoomType(models.Model):
|
|||||||
_sql_constraints = [('code_type_unique', 'unique(code_type)',
|
_sql_constraints = [('code_type_unique', 'unique(code_type)',
|
||||||
'code must be unique!')]
|
'code must be unique!')]
|
||||||
# total number of rooms in this type
|
# total number of rooms in this type
|
||||||
total_rooms_count = fields.Integer(compute='_compute_total_rooms')
|
total_rooms_count = fields.Integer(compute='_compute_total_rooms', store=True)
|
||||||
|
|
||||||
@api.depends('room_ids')
|
@api.depends('room_ids')
|
||||||
def _compute_total_rooms(self):
|
def _compute_total_rooms(self):
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ class ChannelHotelRoomType(models.Model):
|
|||||||
for record in self:
|
for record in self:
|
||||||
if record.ota_capacity < 1:
|
if record.ota_capacity < 1:
|
||||||
raise ValidationError(_("OTA's capacity can't be less than one"))
|
raise ValidationError(_("OTA's capacity can't be less than one"))
|
||||||
|
if record.ota_capacity > record.capacity:
|
||||||
|
raise ValidationError(_("OTA's capacity can't be greater than room type capacity"))
|
||||||
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.constrains('channel_short_code')
|
@api.constrains('channel_short_code')
|
||||||
@@ -138,17 +141,13 @@ class HotelRoomType(models.Model):
|
|||||||
inverse_name='odoo_id',
|
inverse_name='odoo_id',
|
||||||
string='Hotel Channel Connector Bindings')
|
string='Hotel Channel Connector Bindings')
|
||||||
|
|
||||||
capacity = fields.Integer("Capacity", compute="_compute_capacity")
|
capacity = fields.Integer("Capacity", compute="_compute_capacity", store=True)
|
||||||
|
|
||||||
@api.multi
|
@api.depends('room_ids')
|
||||||
def _compute_capacity(self):
|
def _compute_capacity(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
record.capacity = record.get_capacity()
|
record.capacity = record.get_capacity()
|
||||||
|
|
||||||
@api.onchange('room_ids')
|
|
||||||
def _onchange_room_ids(self):
|
|
||||||
self._compute_capacity()
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def get_restrictions(self, date, restriction_plan_id):
|
def get_restrictions(self, date, restriction_plan_id):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
@@ -201,9 +200,6 @@ class BindingHotelRoomTypeListener(Component):
|
|||||||
for binding in record.channel_bind_ids:
|
for binding in record.channel_bind_ids:
|
||||||
binding.modify_room()
|
binding.modify_room()
|
||||||
|
|
||||||
# @skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
|
|
||||||
# def on_record_create(self, record, fields=None):
|
|
||||||
# record.create_bindings()
|
|
||||||
|
|
||||||
class ChannelBindingRoomTypeListener(Component):
|
class ChannelBindingRoomTypeListener(Component):
|
||||||
_name = 'channel.binding.room.type.listener'
|
_name = 'channel.binding.room.type.listener'
|
||||||
|
|||||||
Reference in New Issue
Block a user