[WIP] Update default availability for segmentation management

This commit is contained in:
Pablo
2019-03-10 20:09:14 +01:00
committed by Dario Lodeiros
parent c618847ec2
commit aaba2a1685
3 changed files with 38 additions and 0 deletions

View File

@@ -14,3 +14,5 @@ from . import inherited_hotel_folio
from . import channel_ota_info
from . import hotel_channel_connector_issue
from . import inherited_hotel_board_service_room_type
from . import inherited_hotel_room_type_class
from . import inherited_hotel_room

View File

@@ -133,6 +133,7 @@ class ChannelHotelRoomType(models.Model):
deleter = work.component(usage='hotel.room.type.deleter')
deleter.delete_room(self)
class HotelRoomType(models.Model):
_inherit = 'hotel.room.type'

View File

@@ -0,0 +1,35 @@
# Copyright 2019 Pablo Q. Barriuso <pabloqb@gmail.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, api
class HotelRoom(models.Model):
_inherit = 'hotel.room'
@api.multi
def write(self, vals):
"""
Update default availability for segmentation management
"""
if vals.get('room_type_id'):
room_type_ids = []
for record in self:
room_type_ids.append({
'new_room_type_id': vals.get('room_type_id'),
'old_room_type_id': record.room_type_id.id,
})
res = super().write(vals)
for item in room_type_ids:
if item['new_room_type_id'] != item['old_room_type_id']:
self.env['channel.hotel.room.type'].search(
[('odoo_id', '=', item['old_room_type_id'])]
)._onchange_availability()
self.env['channel.hotel.room.type'].search(
[('odoo_id', '=', item['new_room_type_id'])]
)._onchange_availability()
else:
res = super().write(vals)
return res