mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Manage board services in WuBook rooms
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
from odoo import api, models, fields, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.addons import decimal_precision as dp
|
||||
from odoo.addons.queue_job.job import job
|
||||
from odoo.addons.component.core import Component
|
||||
from odoo.addons.component_event import skip_if
|
||||
@@ -18,8 +19,12 @@ class ChannelHotelRoomType(models.Model):
|
||||
string='Room Type',
|
||||
required=True,
|
||||
ondelete='cascade')
|
||||
channel_short_code = fields.Char("Channel Short Code", readonly=True, old_name='wscode')
|
||||
channel_short_code = fields.Char("Channel Short Code", old_name='wscode')
|
||||
ota_capacity = fields.Integer("OTA's Capacity", default=1, old_name='wcapacity')
|
||||
min_price = fields.Float('Min. Price', default=5.0, digits=dp.get_precision('Product Price'),
|
||||
help="Setup the min price to prevent incidents while editing your prices.")
|
||||
max_price = fields.Float('Max. Price', default=200.0, digits=dp.get_precision('Product Price'),
|
||||
help="Setup the max price to prevent incidents while editing your prices.")
|
||||
|
||||
@api.onchange('room_ids')
|
||||
def _get_capacity(self):
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
<field name="channel_short_code" />
|
||||
<field name="ota_capacity" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="min_price" class="oe_inline"/>
|
||||
<field name="max_price" class="oe_inline"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -122,6 +122,8 @@ class WuBookAdapter(AbstractComponent):
|
||||
|
||||
# === ROOMS
|
||||
def create_room(self, shortcode, name, capacity, price, availability, defboard, rtype):
|
||||
import wdb;
|
||||
wdb.set_trace()
|
||||
rcode, results = self._server.new_room(
|
||||
self._session_info[0],
|
||||
self._session_info[1],
|
||||
@@ -140,7 +142,8 @@ class WuBookAdapter(AbstractComponent):
|
||||
})
|
||||
return results
|
||||
|
||||
def modify_room(self, channel_room_id, name, capacity, price, availability, scode, defboard, rtype):
|
||||
def modify_room(self, channel_room_id, name, capacity, price, availability, scode, defboard,
|
||||
names, descriptions, boards, min_price, max_price, rtype):
|
||||
rcode, results = self._server.mod_room(
|
||||
self._session_info[0],
|
||||
self._session_info[1],
|
||||
@@ -151,7 +154,13 @@ class WuBookAdapter(AbstractComponent):
|
||||
availability,
|
||||
scode,
|
||||
defboard,
|
||||
rtype
|
||||
names,
|
||||
descriptions,
|
||||
boards,
|
||||
min_price,
|
||||
max_price,
|
||||
int(rtype),
|
||||
False,
|
||||
)
|
||||
if rcode != 0:
|
||||
raise ChannelConnectorError(_("Can't modify room in WuBook"), {
|
||||
|
||||
@@ -16,9 +16,11 @@ class HotelRoomTypeAdapter(Component):
|
||||
def fetch_rooms(self):
|
||||
return super(HotelRoomTypeAdapter, self).fetch_rooms()
|
||||
|
||||
def modify_room(self, channel_room_id, name, capacity, price, availability, scode, defboard, rtype):
|
||||
def modify_room(self, channel_room_id, name, capacity, price, availability, scode, defboard,
|
||||
names, descriptions, boards, min_price, max_price, rtype):
|
||||
return super(HotelRoomTypeAdapter, self).modify_room(
|
||||
channel_room_id, name, capacity, price, availability, scode, defboard, rtype)
|
||||
channel_room_id, name, capacity, price, availability, scode, defboard,
|
||||
names, descriptions, boards, min_price, max_price, rtype)
|
||||
|
||||
def delete_room(self, channel_room_id):
|
||||
return super(HotelRoomTypeAdapter, self).delete_room(channel_room_id)
|
||||
|
||||
@@ -15,6 +15,14 @@ class HotelRoomTypeExporter(Component):
|
||||
binding.with_context({
|
||||
'connector_no_export': True,
|
||||
}).write({'sync_date': fields.Datetime.now()})
|
||||
# TODO: do not write if backend_adapter.modify_room through an error
|
||||
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}}
|
||||
)
|
||||
return self.backend_adapter.modify_room(
|
||||
binding.external_id,
|
||||
binding.name,
|
||||
@@ -23,7 +31,13 @@ class HotelRoomTypeExporter(Component):
|
||||
binding.total_rooms_count,
|
||||
binding.channel_short_code,
|
||||
'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