mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] WIP
This commit is contained in:
@@ -97,10 +97,12 @@ class ChannelHotelReservation(models.Model):
|
|||||||
|
|
||||||
channel_room_type_avail_obj = self.env['channel.hotel.room.type.availability']
|
channel_room_type_avail_obj = self.env['channel.hotel.room.type.availability']
|
||||||
for k_i, v_i in enumerate(older_vals):
|
for k_i, v_i in enumerate(older_vals):
|
||||||
|
# FIX: 3rd parameters is backend_id, use room_id=v_i['room_id'] instead
|
||||||
channel_room_type_avail_obj.refresh_availability(
|
channel_room_type_avail_obj.refresh_availability(
|
||||||
v_i['checkin'],
|
v_i['checkin'],
|
||||||
v_i['checkout'],
|
v_i['checkout'],
|
||||||
v_i['room_id'])
|
v_i['room_id'])
|
||||||
|
# FIX: 3rd parameters is backend_id, use room_id=new_vals[k_i]['room_id'] instead
|
||||||
channel_room_type_avail_obj.refresh_availability(
|
channel_room_type_avail_obj.refresh_availability(
|
||||||
new_vals[k_i]['checkin'],
|
new_vals[k_i]['checkin'],
|
||||||
new_vals[k_i]['checkout'],
|
new_vals[k_i]['checkout'],
|
||||||
@@ -124,6 +126,7 @@ class ChannelHotelReservation(models.Model):
|
|||||||
if self._context.get('connector_no_export', True):
|
if self._context.get('connector_no_export', True):
|
||||||
channel_room_type_avail_obj = self.env['channel.hotel.room.type.availability']
|
channel_room_type_avail_obj = self.env['channel.hotel.room.type.availability']
|
||||||
for record in vals:
|
for record in vals:
|
||||||
|
# FIX: 3rd parameters is backend_id, use room_id=record['room_id'] instead
|
||||||
channel_room_type_avail_obj.refresh_availability(
|
channel_room_type_avail_obj.refresh_availability(
|
||||||
record['checkin'],
|
record['checkin'],
|
||||||
record['checkout'],
|
record['checkout'],
|
||||||
@@ -180,7 +183,20 @@ class HotelReservation(models.Model):
|
|||||||
user = self.env['res.users'].browse(self.env.uid)
|
user = self.env['res.users'].browse(self.env.uid)
|
||||||
if user.has_group('hotel.group_hotel_call'):
|
if user.has_group('hotel.group_hotel_call'):
|
||||||
vals.update({'to_read': True})
|
vals.update({'to_read': True})
|
||||||
return super(HotelReservation, self).create(vals)
|
|
||||||
|
reservation_id = super(HotelReservation, self).create(vals)
|
||||||
|
# restar quota si en viene de wubook y es mayor que cero
|
||||||
|
backend_id = self.env['channel.hotel.room.type'].search([
|
||||||
|
('odoo_id', '=', vals['room_type_id'])
|
||||||
|
]).backend_id
|
||||||
|
# WARNING: more than one backend_id is currently not expected
|
||||||
|
self.env['channel.hotel.room.type.availability'].refresh_availability(
|
||||||
|
vals['real_checkin'],
|
||||||
|
vals['real_checkout'],
|
||||||
|
backend_id.id,
|
||||||
|
room_id=vals['room_type_id'])
|
||||||
|
|
||||||
|
return reservation_id
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def generate_copy_values(self, checkin=False, checkout=False):
|
def generate_copy_values(self, checkin=False, checkout=False):
|
||||||
|
|||||||
@@ -16,6 +16,14 @@ class ChannelHotelRoomType(models.Model):
|
|||||||
_inherits = {'hotel.room.type': 'odoo_id'}
|
_inherits = {'hotel.room.type': 'odoo_id'}
|
||||||
_description = 'Channel Hotel Room'
|
_description = 'Channel Hotel Room'
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _default_availability(self):
|
||||||
|
room_type_id = self._context.get('room_type_id')
|
||||||
|
if room_type_id:
|
||||||
|
room_type_id = self.env['hotel.room_type'].browse(room_type_id)
|
||||||
|
return room_type_id.default_quota if room_type_id else -1
|
||||||
|
return -1
|
||||||
|
|
||||||
odoo_id = fields.Many2one(comodel_name='hotel.room.type',
|
odoo_id = fields.Many2one(comodel_name='hotel.room.type',
|
||||||
string='Room Type',
|
string='Room Type',
|
||||||
required=True,
|
required=True,
|
||||||
@@ -23,8 +31,14 @@ class ChannelHotelRoomType(models.Model):
|
|||||||
channel_short_code = fields.Char("Channel Short Code", 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',
|
ota_capacity = fields.Integer("OTA's Capacity", default=1, old_name='wcapacity',
|
||||||
help="The capacity of the room for OTAs.")
|
help="The capacity of the room for OTAs.")
|
||||||
default_availability = fields.Integer(default=0,
|
|
||||||
|
default_quota = fields.Integer("Default Quota", default=-1,
|
||||||
|
help="Quota assigned to the channel given no availability rules.")
|
||||||
|
default_max_avail = fields.Integer("Max. Availability", default=-1,
|
||||||
|
help="Maximum simultaneous availability given no quota.")
|
||||||
|
default_availability = fields.Integer(readonly=True, default=_default_availability,
|
||||||
help="Default availability for OTAs.")
|
help="Default availability for OTAs.")
|
||||||
|
|
||||||
min_price = fields.Float('Min. Price', default=5.0, digits=dp.get_precision('Product Price'),
|
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.")
|
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'),
|
max_price = fields.Float('Max. Price', default=200.0, digits=dp.get_precision('Product Price'),
|
||||||
@@ -94,7 +108,6 @@ class HotelRoomType(models.Model):
|
|||||||
inverse_name='odoo_id',
|
inverse_name='odoo_id',
|
||||||
string='Hotel Channel Connector Bindings')
|
string='Hotel Channel Connector Bindings')
|
||||||
|
|
||||||
default_quota = fields.Integer("Default Quota", compute="_compute_capacity")
|
|
||||||
capacity = fields.Integer("Capacity", compute="_compute_capacity")
|
capacity = fields.Integer("Capacity", compute="_compute_capacity")
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ class ChannelHotelRoomTypeAvailability(models.Model):
|
|||||||
domain = [('backend_id', '=', backend_id)]
|
domain = [('backend_id', '=', backend_id)]
|
||||||
if room_id:
|
if room_id:
|
||||||
domain.append(('room_ids', 'in', [room_id]))
|
domain.append(('room_ids', 'in', [room_id]))
|
||||||
# WARNING: more than one binding is currently not expected
|
|
||||||
room_type_bind = channel_room_type_obj.search(domain, limit=1)
|
room_type_bind = channel_room_type_obj.search(domain, limit=1)
|
||||||
if room_type_bind and room_type_bind.external_id:
|
if room_type_bind and room_type_bind.external_id:
|
||||||
_logger.info("==[ODOO->CHANNEL]==== REFRESH AVAILABILITY ==")
|
_logger.info("==[ODOO->CHANNEL]==== REFRESH AVAILABILITY ==")
|
||||||
@@ -166,7 +165,6 @@ class ChannelHotelRoomTypeAvailability(models.Model):
|
|||||||
else:
|
else:
|
||||||
# default availability for OTAs if not record given
|
# default availability for OTAs if not record given
|
||||||
# This should happens only when refreshing availability from hotel.reservation
|
# This should happens only when refreshing availability from hotel.reservation
|
||||||
import wdb; wdb.set_trace()
|
|
||||||
to_eval.append(room_type_bind.default_availability)
|
to_eval.append(room_type_bind.default_availability)
|
||||||
|
|
||||||
avail = max(min(to_eval), 0)
|
avail = max(min(to_eval), 0)
|
||||||
@@ -187,11 +185,12 @@ class ChannelHotelRoomTypeAvailability(models.Model):
|
|||||||
room_type_avail_id.write({'channel_avail': avail})
|
room_type_avail_id.write({'channel_avail': avail})
|
||||||
else:
|
else:
|
||||||
# This should happens only when refreshing availability from hotel.reservation
|
# This should happens only when refreshing availability from hotel.reservation
|
||||||
import wdb; wdb.set_trace()
|
|
||||||
channel_room_type_avail_obj.create({
|
channel_room_type_avail_obj.create({
|
||||||
'room_type_id': room_type_bind.odoo_id.id,
|
'odoo_id': room_type_bind.odoo_id.id,
|
||||||
|
'backend_id': backend_id,
|
||||||
'date': ndate_str,
|
'date': ndate_str,
|
||||||
'channel_avail': avail,
|
'channel_avail': avail,
|
||||||
|
'channel_pushed': False,
|
||||||
})
|
})
|
||||||
|
|
||||||
@job(default_channel='root.channel')
|
@job(default_channel='root.channel')
|
||||||
@@ -276,7 +275,9 @@ class ChannelBindingHotelRoomTypeAvailabilityListener(Component):
|
|||||||
_logger.info(fields)
|
_logger.info(fields)
|
||||||
|
|
||||||
if any(fields_checked):
|
if any(fields_checked):
|
||||||
|
# self.env['channel.backend'].cron_push_changes()
|
||||||
record.channel_pushed = False
|
record.channel_pushed = False
|
||||||
|
record.push_availability(record.backend_id)
|
||||||
|
|
||||||
@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
|
@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
|
||||||
def on_fix_channel_availability(self, record, fields=None):
|
def on_fix_channel_availability(self, record, fields=None):
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="quota" />
|
<field name="quota" />
|
||||||
|
<field name="channel_avail" />
|
||||||
<field name="booked" />
|
<field name="booked" />
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
@@ -28,6 +29,7 @@
|
|||||||
<tree string="Hotel Channel Room Availability">
|
<tree string="Hotel Channel Room Availability">
|
||||||
<field name="backend_id" />
|
<field name="backend_id" />
|
||||||
<field name="quota" />
|
<field name="quota" />
|
||||||
|
<field name="channel_avail" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user