mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] creating room type with channel arguments
This commit is contained in:
@@ -53,7 +53,7 @@ class ChannelHotelRoomType(models.Model):
|
||||
@api.constrains('channel_short_code')
|
||||
def _check_channel_short_code(self):
|
||||
for record in self:
|
||||
if len(record.channel_short_code) > 4: # Wubook scode max. length
|
||||
if self.channel_short_code and len(record.channel_short_code) > 4: # Wubook scode max. length
|
||||
raise ValidationError(_("Chanel short code can't be longer than 4 characters"))
|
||||
|
||||
@job(default_channel='root.channel')
|
||||
@@ -123,6 +123,10 @@ class HotelRoomType(models.Model):
|
||||
# WARNING: more than one binding is currently not expected
|
||||
action['domain'] = [('id', 'in', channel_bind_ids.ids)]
|
||||
else:
|
||||
action['context'] = {'default_odoo_id': self.id,
|
||||
'default_name': self.name,
|
||||
'default_ota_capacity': self.capacity,
|
||||
'default_list_price': self.list_price}
|
||||
action['target'] = 'new'
|
||||
return action
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
<field name="channel_service" />
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -121,9 +121,8 @@ class WuBookAdapter(AbstractComponent):
|
||||
return rcode_a == 0 and results_b == 0
|
||||
|
||||
# === ROOMS
|
||||
def create_room(self, shortcode, name, capacity, price, availability, defboard, rtype):
|
||||
import wdb;
|
||||
wdb.set_trace()
|
||||
def create_room(self, shortcode, name, capacity, price, availability, defboard,
|
||||
names, descriptions, boards, min_price, max_price, rtype):
|
||||
rcode, results = self._server.new_room(
|
||||
self._session_info[0],
|
||||
self._session_info[1],
|
||||
@@ -132,9 +131,14 @@ class WuBookAdapter(AbstractComponent):
|
||||
capacity,
|
||||
price,
|
||||
availability,
|
||||
shortcode[:4],
|
||||
shortcode,
|
||||
defboard,
|
||||
rtype
|
||||
names,
|
||||
descriptions,
|
||||
boards,
|
||||
int(rtype),
|
||||
# min_price,
|
||||
# max_price,
|
||||
)
|
||||
if rcode != 0:
|
||||
raise ChannelConnectorError(_("Can't create room in WuBook"), {
|
||||
@@ -160,7 +164,7 @@ class WuBookAdapter(AbstractComponent):
|
||||
min_price,
|
||||
max_price,
|
||||
int(rtype),
|
||||
False,
|
||||
0,
|
||||
)
|
||||
if rcode != 0:
|
||||
raise ChannelConnectorError(_("Can't modify room in WuBook"), {
|
||||
|
||||
@@ -9,9 +9,11 @@ class HotelRoomTypeAdapter(Component):
|
||||
_inherit = 'wubook.adapter'
|
||||
_apply_on = 'channel.hotel.room.type'
|
||||
|
||||
def create_room(self, shortcode, name, capacity, price, availability, defboard, rtype):
|
||||
def create_room(self, shortcode, name, capacity, price, availability, defboard,
|
||||
names, descriptions, boards, min_price, max_price, rtype):
|
||||
return super(HotelRoomTypeAdapter, self).create_room(
|
||||
shortcode, name, capacity, price, availability, defboard, rtype)
|
||||
shortcode, name, capacity, price, availability, defboard,
|
||||
names, descriptions, boards, min_price, max_price, rtype)
|
||||
|
||||
def fetch_rooms(self):
|
||||
return super(HotelRoomTypeAdapter, self).fetch_rooms()
|
||||
|
||||
@@ -49,6 +49,13 @@ class HotelRoomTypeExporter(Component):
|
||||
seq_obj = self.env['ir.sequence']
|
||||
short_code = seq_obj.next_by_code('hotel.room.type')[:4]
|
||||
try:
|
||||
boards = {}
|
||||
for board in binding.board_service_room_type_ids:
|
||||
boards.update(
|
||||
{board.channel_service: {
|
||||
'dtype': 2 if board.price_type == 'fixed' else 1,
|
||||
'value': board.amount}}
|
||||
)
|
||||
external_id = self.backend_adapter.create_room(
|
||||
short_code,
|
||||
binding.name,
|
||||
@@ -56,7 +63,13 @@ class HotelRoomTypeExporter(Component):
|
||||
binding.list_price,
|
||||
binding.total_rooms_count,
|
||||
'nb',
|
||||
binding.class_id and binding.class_id.code_class or False)
|
||||
{},
|
||||
{},
|
||||
boards,
|
||||
binding.min_price,
|
||||
binding.max_price,
|
||||
binding.class_id and binding.class_id.code_class or False,
|
||||
)
|
||||
except ChannelConnectorError as err:
|
||||
self.create_issue(
|
||||
section='room',
|
||||
|
||||
Reference in New Issue
Block a user