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')
|
@api.constrains('channel_short_code')
|
||||||
def _check_channel_short_code(self):
|
def _check_channel_short_code(self):
|
||||||
for record in 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"))
|
raise ValidationError(_("Chanel short code can't be longer than 4 characters"))
|
||||||
|
|
||||||
@job(default_channel='root.channel')
|
@job(default_channel='root.channel')
|
||||||
@@ -123,6 +123,10 @@ class HotelRoomType(models.Model):
|
|||||||
# WARNING: more than one binding is currently not expected
|
# WARNING: more than one binding is currently not expected
|
||||||
action['domain'] = [('id', 'in', channel_bind_ids.ids)]
|
action['domain'] = [('id', 'in', channel_bind_ids.ids)]
|
||||||
else:
|
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'
|
action['target'] = 'new'
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
<field name="channel_service" />
|
<field name="channel_service" />
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
|
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -121,9 +121,8 @@ class WuBookAdapter(AbstractComponent):
|
|||||||
return rcode_a == 0 and results_b == 0
|
return rcode_a == 0 and results_b == 0
|
||||||
|
|
||||||
# === ROOMS
|
# === ROOMS
|
||||||
def create_room(self, shortcode, name, capacity, price, availability, defboard, rtype):
|
def create_room(self, shortcode, name, capacity, price, availability, defboard,
|
||||||
import wdb;
|
names, descriptions, boards, min_price, max_price, rtype):
|
||||||
wdb.set_trace()
|
|
||||||
rcode, results = self._server.new_room(
|
rcode, results = self._server.new_room(
|
||||||
self._session_info[0],
|
self._session_info[0],
|
||||||
self._session_info[1],
|
self._session_info[1],
|
||||||
@@ -132,9 +131,14 @@ class WuBookAdapter(AbstractComponent):
|
|||||||
capacity,
|
capacity,
|
||||||
price,
|
price,
|
||||||
availability,
|
availability,
|
||||||
shortcode[:4],
|
shortcode,
|
||||||
defboard,
|
defboard,
|
||||||
rtype
|
names,
|
||||||
|
descriptions,
|
||||||
|
boards,
|
||||||
|
int(rtype),
|
||||||
|
# min_price,
|
||||||
|
# max_price,
|
||||||
)
|
)
|
||||||
if rcode != 0:
|
if rcode != 0:
|
||||||
raise ChannelConnectorError(_("Can't create room in WuBook"), {
|
raise ChannelConnectorError(_("Can't create room in WuBook"), {
|
||||||
@@ -160,7 +164,7 @@ class WuBookAdapter(AbstractComponent):
|
|||||||
min_price,
|
min_price,
|
||||||
max_price,
|
max_price,
|
||||||
int(rtype),
|
int(rtype),
|
||||||
False,
|
0,
|
||||||
)
|
)
|
||||||
if rcode != 0:
|
if rcode != 0:
|
||||||
raise ChannelConnectorError(_("Can't modify room in WuBook"), {
|
raise ChannelConnectorError(_("Can't modify room in WuBook"), {
|
||||||
|
|||||||
@@ -9,9 +9,11 @@ class HotelRoomTypeAdapter(Component):
|
|||||||
_inherit = 'wubook.adapter'
|
_inherit = 'wubook.adapter'
|
||||||
_apply_on = 'channel.hotel.room.type'
|
_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(
|
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):
|
def fetch_rooms(self):
|
||||||
return super(HotelRoomTypeAdapter, self).fetch_rooms()
|
return super(HotelRoomTypeAdapter, self).fetch_rooms()
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ class HotelRoomTypeExporter(Component):
|
|||||||
seq_obj = self.env['ir.sequence']
|
seq_obj = self.env['ir.sequence']
|
||||||
short_code = seq_obj.next_by_code('hotel.room.type')[:4]
|
short_code = seq_obj.next_by_code('hotel.room.type')[:4]
|
||||||
try:
|
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(
|
external_id = self.backend_adapter.create_room(
|
||||||
short_code,
|
short_code,
|
||||||
binding.name,
|
binding.name,
|
||||||
@@ -56,7 +63,13 @@ class HotelRoomTypeExporter(Component):
|
|||||||
binding.list_price,
|
binding.list_price,
|
||||||
binding.total_rooms_count,
|
binding.total_rooms_count,
|
||||||
'nb',
|
'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:
|
except ChannelConnectorError as err:
|
||||||
self.create_issue(
|
self.create_issue(
|
||||||
section='room',
|
section='room',
|
||||||
|
|||||||
Reference in New Issue
Block a user