mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Update default availability for segmentation management
This commit is contained in:
@@ -14,3 +14,5 @@ from . import inherited_hotel_folio
|
|||||||
from . import channel_ota_info
|
from . import channel_ota_info
|
||||||
from . import hotel_channel_connector_issue
|
from . import hotel_channel_connector_issue
|
||||||
from . import inherited_hotel_board_service_room_type
|
from . import inherited_hotel_board_service_room_type
|
||||||
|
from . import inherited_hotel_room_type_class
|
||||||
|
from . import inherited_hotel_room
|
||||||
@@ -133,6 +133,7 @@ class ChannelHotelRoomType(models.Model):
|
|||||||
deleter = work.component(usage='hotel.room.type.deleter')
|
deleter = work.component(usage='hotel.room.type.deleter')
|
||||||
deleter.delete_room(self)
|
deleter.delete_room(self)
|
||||||
|
|
||||||
|
|
||||||
class HotelRoomType(models.Model):
|
class HotelRoomType(models.Model):
|
||||||
_inherit = 'hotel.room.type'
|
_inherit = 'hotel.room.type'
|
||||||
|
|
||||||
|
|||||||
35
hotel_channel_connector/models/inherited_hotel_room.py
Normal file
35
hotel_channel_connector/models/inherited_hotel_room.py
Normal 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
|
||||||
Reference in New Issue
Block a user