mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP][MIG][11.0] Odoo Connector
This commit is contained in:
@@ -24,9 +24,9 @@
|
||||
'views/actions.xml',
|
||||
'views/res_config_views.xml',
|
||||
'views/inherited_res_users_views.xml',
|
||||
'views/inherited_hotel_virtual_room_views.xml',
|
||||
'views/inherited_hotel_room_type_views.xml',
|
||||
'views/inherited_hotel_room_views.xml',
|
||||
'views/virtual_room_pricelist_cached_views.xml',
|
||||
'views/room_pricelist_cached_views.xml',
|
||||
'data/views.xml',
|
||||
'data/menus.xml',
|
||||
'data/records.xml',
|
||||
|
||||
@@ -4,13 +4,15 @@ from . import inherited_hotel_reservation
|
||||
from . import inherited_product_pricelist_item
|
||||
from . import inherited_res_users
|
||||
from . import bus_hotel_calendar
|
||||
from . import virtual_room_pricelist_cached
|
||||
from . import room_pricelist_cached
|
||||
from . import hotel_calendar_management
|
||||
from . import res_config
|
||||
from . import inherited_hotel_virtual_room
|
||||
from . import inherited_hotel_room
|
||||
from . import inherited_hotel_room_type
|
||||
from . import inherited_hotel_virtual_room_restriction_item
|
||||
from . import inherited_hotel_virtual_room_availability
|
||||
from . import inherited_product_pricelist
|
||||
from . import inherited_hotel_folio
|
||||
from . import inherited_ir_default
|
||||
from . import inherited_ir_actions_act_window_view
|
||||
from . import inherited_ir_ui_view
|
||||
|
||||
@@ -77,7 +77,7 @@ class BusHotelCalendar(models.TransientModel):
|
||||
'days': {
|
||||
date_dt.strftime("%d/%m/%Y"): vals['price'],
|
||||
},
|
||||
'room': vals['virtual_room_id'],
|
||||
'room': vals['room_id'],
|
||||
'id': vals['id'],
|
||||
}],
|
||||
},
|
||||
@@ -89,7 +89,7 @@ class BusHotelCalendar(models.TransientModel):
|
||||
return {
|
||||
'type': 'restriction',
|
||||
'restriction': {
|
||||
vals['virtual_room_id']: {
|
||||
vals['room_id']: {
|
||||
date_dt.strftime("%d/%m/%Y"): [
|
||||
vals['min_stay'],
|
||||
vals['min_stay_arrival'],
|
||||
@@ -110,7 +110,7 @@ class BusHotelCalendar(models.TransientModel):
|
||||
return {
|
||||
'type': 'availability',
|
||||
'availability': {
|
||||
vals['virtual_room_id']: {
|
||||
vals['room_id']: {
|
||||
date_dt.strftime("%d/%m/%Y"): [
|
||||
vals['avail'],
|
||||
vals['no_ota'],
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class HotelVirtualRoom(models.Model):
|
||||
class HotelRoomType(models.Model):
|
||||
_inherit = 'hotel.room.type'
|
||||
|
||||
hcal_sequence = fields.Integer('Calendar Sequence', default=0)
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
vroom_pr_cached_obj = self.env['virtual.room.pricelist.cached']
|
||||
room_type_pr_cached_obj = self.env['hotel.room.pricelist.cached']
|
||||
for record in self:
|
||||
pr_chached = vroom_pr_cached_obj.search([
|
||||
('virtual_room_id', '=', record.id)
|
||||
pr_chached = room_type_pr_cached_obj.search([
|
||||
('room_id', '=', record.id)
|
||||
])
|
||||
# Because 'pricelist.cached' is an isolated model,
|
||||
# doesn't trigger 'ondelete'. Need call 'unlink' instead.
|
||||
pr_chached.unlink()
|
||||
return super(HotelVirtualRoom, self).unlink()
|
||||
return super(HotelRoomType, self).unlink()
|
||||
@@ -7,13 +7,13 @@ class ProductPricelist(models.Model):
|
||||
_inherit = 'product.pricelist'
|
||||
|
||||
@api.multi
|
||||
def update_price(self, virtual_room_id, date, price):
|
||||
vroom = self.env['hotel.room.type'].browse(virtual_room_id)
|
||||
def update_price(self, room_type_id, date, price):
|
||||
room_type = self.env['hotel.room.type'].browse(room_type_id)
|
||||
pritem_obj = self.env['product.pricelist.item']
|
||||
for record in self:
|
||||
plitem = pritem_obj.search([
|
||||
('pricelist_id', '=', record.id),
|
||||
('product_tmpl_id', '=', vroom.product_id.product_tmpl_id.id),
|
||||
('product_tmpl_id', '=', room_type.product_id.product_tmpl_id.id),
|
||||
('date_start', '=', date),
|
||||
('date_end', '=', date),
|
||||
('applied_on', '=', '1_product'),
|
||||
@@ -24,7 +24,7 @@ class ProductPricelist(models.Model):
|
||||
else:
|
||||
pritem_obj.create({
|
||||
'pricelist_id': record.id,
|
||||
'product_tmpl_id': vroom.product_id.product_tmpl_id.id,
|
||||
'product_tmpl_id': room_type.product_id.product_tmpl_id.id,
|
||||
'date_start': date,
|
||||
'date_end': date,
|
||||
'applied_on': '1_product',
|
||||
|
||||
@@ -10,17 +10,17 @@ class ProductPricelistItem(models.Model):
|
||||
def create(self, vals):
|
||||
res = super(ProductPricelistItem, self).create(vals)
|
||||
pricelist_parity_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_parity_id:
|
||||
pricelist_parity_id = int(pricelist_parity_id)
|
||||
pricelist_id = res.pricelist_id.id
|
||||
product_tmpl_id = res.product_tmpl_id.id
|
||||
date_start = res.date_start
|
||||
vroom = self.env['hotel.room.type'].search([
|
||||
room_type = self.env['hotel.room.type'].search([
|
||||
('product_id.product_tmpl_id', '=', product_tmpl_id)
|
||||
], limit=1)
|
||||
if pricelist_id == pricelist_parity_id and vroom:
|
||||
prod = vroom.product_id.with_context(
|
||||
prod = room_type.product_id.with_context(
|
||||
quantity=1,
|
||||
date=date_start,
|
||||
pricelist=pricelist_id)
|
||||
@@ -29,21 +29,21 @@ class ProductPricelistItem(models.Model):
|
||||
self.env['bus.hotel.calendar'].send_pricelist_notification({
|
||||
'pricelist_id': pricelist_id,
|
||||
'date': date_start,
|
||||
'virtual_room_id': vroom.id,
|
||||
'room_id': room_type.id,
|
||||
'price': prod_price,
|
||||
'id': self.id,
|
||||
})
|
||||
|
||||
vroom_pr_cached_obj = self.env['virtual.room.pricelist.cached']
|
||||
vroom_pr_cached_id = vroom_pr_cached_obj.search([
|
||||
('virtual_room_id', '=', vroom.id),
|
||||
room_pr_cached_obj = self.env['room.pricelist.cached']
|
||||
room_pr_cached_id = room_pr_cached_obj.search([
|
||||
('room_id', '=', room_type.id),
|
||||
('date', '=', date_start),
|
||||
], limit=1)
|
||||
if vroom_pr_cached_id:
|
||||
vroom_pr_cached_id.write({'price': prod_price})
|
||||
if room_pr_cached_id:
|
||||
room_pr_cached_id.write({'price': prod_price})
|
||||
else:
|
||||
vroom_pr_cached_obj.create({
|
||||
'virtual_room_id': vroom.id,
|
||||
room_pr_cached_obj.create({
|
||||
'room_id': room_type.id,
|
||||
'date': date_start,
|
||||
'price': prod_price,
|
||||
})
|
||||
@@ -52,14 +52,14 @@ class ProductPricelistItem(models.Model):
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
pricelist_parity_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_parity_id:
|
||||
pricelist_parity_id = int(pricelist_parity_id)
|
||||
ret_vals = super(ProductPricelistItem, self).write(vals)
|
||||
|
||||
vroom_pr_cached_obj = self.env['virtual.room.pricelist.cached']
|
||||
room_pr_cached_obj = self.env['room.pricelist.cached']
|
||||
bus_calendar_obj = self.env['bus.hotel.calendar']
|
||||
vroom_obj = self.env['hotel.room.type']
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
if vals.get('fixed_price'):
|
||||
for record in self:
|
||||
pricelist_id = vals.get('pricelist_id') or \
|
||||
@@ -69,12 +69,12 @@ class ProductPricelistItem(models.Model):
|
||||
date_start = vals.get('date_start') or record.date_start
|
||||
product_tmpl_id = vals.get('product_tmpl_id') or \
|
||||
record.product_tmpl_id.id
|
||||
vroom = vroom_obj.search([
|
||||
room_type = room_type_obj.search([
|
||||
('product_id.product_tmpl_id', '=', product_tmpl_id)
|
||||
], limit=1)
|
||||
|
||||
if vroom and date_start:
|
||||
prod = vroom.product_id.with_context(
|
||||
if room_type and date_start:
|
||||
prod = room_type.product_id.with_context(
|
||||
quantity=1,
|
||||
date=date_start,
|
||||
pricelist=pricelist_id)
|
||||
@@ -83,20 +83,20 @@ class ProductPricelistItem(models.Model):
|
||||
bus_calendar_obj.send_pricelist_notification({
|
||||
'pricelist_id': pricelist_id,
|
||||
'date': date_start,
|
||||
'virtual_room_id': vroom.id,
|
||||
'room_id': room_type.id,
|
||||
'price': prod_price,
|
||||
'id': record.id,
|
||||
})
|
||||
|
||||
vroom_pr_cached_id = vroom_pr_cached_obj.search([
|
||||
('virtual_room_id', '=', vroom.id),
|
||||
vroom_pr_cached_id = room_pr_cached_obj.search([
|
||||
('room_id', '=', room_type.id),
|
||||
('date', '=', date_start),
|
||||
], limit=1)
|
||||
if vroom_pr_cached_id:
|
||||
vroom_pr_cached_id.write({'price': prod_price})
|
||||
else:
|
||||
vroom_pr_cached_obj.create({
|
||||
'virtual_room_id': vroom.id,
|
||||
room_pr_cached_obj.create({
|
||||
'room_id': room_type.id,
|
||||
'date': date_start,
|
||||
'price': prod_price,
|
||||
})
|
||||
@@ -105,7 +105,7 @@ class ProductPricelistItem(models.Model):
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
pricelist_parity_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_parity_id:
|
||||
pricelist_parity_id = int(pricelist_parity_id)
|
||||
# Construct dictionary with relevant info of removed records
|
||||
@@ -113,25 +113,25 @@ class ProductPricelistItem(models.Model):
|
||||
for record in self:
|
||||
if record.pricelist_id.id != pricelist_parity_id:
|
||||
continue
|
||||
vroom = self.env['hotel.room.type'].search([
|
||||
room_type = self.env['hotel.room.type'].search([
|
||||
('product_id.product_tmpl_id', '=', record.product_tmpl_id.id)
|
||||
], limit=1)
|
||||
unlink_vals.append({
|
||||
'pricelist_id': record.pricelist_id.id,
|
||||
'date': record.date_start,
|
||||
'vroom': vroom,
|
||||
'room': room_type,
|
||||
'id': record.id,
|
||||
})
|
||||
# Do Normal Stuff
|
||||
res = super(ProductPricelistItem, self).unlink()
|
||||
# Do extra operations
|
||||
vroom_pr_cached_obj = self.env['virtual.room.pricelist.cached']
|
||||
room_pr_cached_obj = self.env['room.pricelist.cached']
|
||||
bus_calendar_obj = self.env['bus.hotel.calendar']
|
||||
for vals in unlink_vals:
|
||||
pricelist_id = vals['pricelist_id']
|
||||
date_start = vals['date']
|
||||
vroom = vals['vroom']
|
||||
prod = vroom.product_id.with_context(
|
||||
room_type = vals['room']
|
||||
prod = room_type.product_id.with_context(
|
||||
quantity=1,
|
||||
date=date_start,
|
||||
pricelist=pricelist_id)
|
||||
@@ -140,16 +140,16 @@ class ProductPricelistItem(models.Model):
|
||||
bus_calendar_obj.send_pricelist_notification({
|
||||
'pricelist_id': pricelist_id,
|
||||
'date': date_start,
|
||||
'virtual_room_id': vroom.id,
|
||||
'room_id': room_type.id,
|
||||
'price': prod.price,
|
||||
'id': vals['id'],
|
||||
})
|
||||
|
||||
# Remove records from cache model
|
||||
vroom_pr_cached_id = vroom_pr_cached_obj.search([
|
||||
('virtual_room_id', '=', vroom.id),
|
||||
room_pr_cached_id = room_pr_cached_obj.search([
|
||||
('room_id', '=', room_type.id),
|
||||
('date', '=', date_start),
|
||||
], limit=1)
|
||||
if vroom_pr_cached_id:
|
||||
vroom_pr_cached_id.unlink()
|
||||
if room_pr_cached_id:
|
||||
room_pr_cached_id.unlink()
|
||||
return res
|
||||
|
||||
@@ -4,14 +4,14 @@ from odoo import models, fields, api
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class VirtualRoomPricelistCached(models.Model):
|
||||
class RoomPricelistCached(models.Model):
|
||||
'''
|
||||
Cached Pricelist. Used only for Calendar Values
|
||||
'''
|
||||
|
||||
_name = 'virtual.room.pricelist.cached'
|
||||
_name = 'room.pricelist.cached'
|
||||
|
||||
virtual_room_id = fields.Many2one('hotel.room.type', 'Virtual Room',
|
||||
required=True, track_visibility='always')
|
||||
room_id = fields.Many2one('hotel.room.type', 'Virtual Room',
|
||||
required=True, track_visibility='always')
|
||||
price = fields.Float('Price', default=0.0)
|
||||
date = fields.Date('Date', required=True, track_visibility='always')
|
||||
@@ -199,7 +199,7 @@ var PMSCalendarController = AbstractController.extend({
|
||||
this.model.get_room_types(),
|
||||
this.model.get_floors(),
|
||||
this.model.get_amenities(),
|
||||
this.model.get_vrooms()
|
||||
this.model.get_rooms()
|
||||
).then(function(a1, a2, a3, a4){
|
||||
self.renderer.loadViewFilters(a1, a2, a3, a4);
|
||||
});
|
||||
|
||||
@@ -80,7 +80,7 @@ return AbstractModel.extend({
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
get_vrooms: function() {
|
||||
get_rooms: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.room.type',
|
||||
method: 'search_read',
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record model="ir.actions.act_window" id="hotel_reservation_action_checkin">
|
||||
<field name="name">Hotel folio checkin</field>
|
||||
<field name="res_model">hotel.reservation</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('is_checkin','=', True)]</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="hotel_reservation_action_checkin">
|
||||
<field name="name">Hotel folio checkin</field>
|
||||
<field name="res_model">hotel.reservation</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('is_checkin','=', True)]</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="hotel_reservation_action_checkout">
|
||||
<field name="name">Hotel folio checkout</field>
|
||||
<field name="res_model">hotel.reservation</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('is_checkout','=', True)]</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="hotel_reservation_action_checkout">
|
||||
<field name="name">Hotel folio checkout</field>
|
||||
<field name="res_model">hotel.reservation</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('is_checkout','=', True)]</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="hotel_virtual_room_pricelist_cached_action_form_tree">
|
||||
<field name="name">Virtual Room Pricelist Cached</field>
|
||||
<field name="res_model">virtual.room.pricelist.cached</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="hotel_room_pricelist_cached_action_form_tree">
|
||||
<field name="name">Room Pricelist Cached</field>
|
||||
<field name="res_model">room.pricelist.cached</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Use an updated momentJS library -->
|
||||
<template id="assets_common" inherit_id="web.assets_common">
|
||||
<xpath expr="//script[@src='/web/static/lib/moment/moment.js']" position="attributes">
|
||||
<attribute name="src">/hotel_calendar/static/src/lib/moment.js</attribute>
|
||||
</xpath>
|
||||
</template>
|
||||
<!-- Use an updated momentJS library -->
|
||||
<template id="assets_common" inherit_id="web.assets_common">
|
||||
<xpath expr="//script[@src='/web/static/lib/moment/moment.js']" position="attributes">
|
||||
<attribute name="src">/hotel_calendar/static/src/lib/moment.js</attribute>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Backend stuff -->
|
||||
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/lib/bootbox.js"></script>
|
||||
<!-- Backend stuff -->
|
||||
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/lib/bootbox.js"></script>
|
||||
|
||||
<!-- Hotel Calendar (Internal) -->
|
||||
<link rel="stylesheet" href="/hotel_calendar/static/src/css/view.css" />
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/constants.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_model.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_renderer.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_view.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_controller.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_model.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_renderer.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_view.js"></script>
|
||||
<!-- Hotel Calendar (Internal) -->
|
||||
<link rel="stylesheet" href="/hotel_calendar/static/src/css/view.css" />
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/constants.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_model.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_renderer.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_view.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_controller.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_model.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_renderer.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_view.js"></script>
|
||||
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/open_reservation_wizard_listview_button.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/open_reservation_wizard_listview_button.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
|
||||
14
hotel_calendar/views/inherited_hotel_room_type_views.xml
Normal file
14
hotel_calendar/views/inherited_hotel_room_type_views.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record id="virtual_room_view_form" model="ir.ui.view">
|
||||
<field name="model">hotel.room.type</field>
|
||||
<field name="inherit_id" ref="hotel.view_hotel_room_type_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="hcal_sequence" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record id="room_view_form" model="ir.ui.view">
|
||||
<record id="room_view_form" model="ir.ui.view">
|
||||
<field name="model">hotel.room</field>
|
||||
<field name="inherit_id" ref="hotel.view_hotel_room_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='to_be_cleaned']" position="after">
|
||||
<field name="hcal_sequence" />
|
||||
</xpath>
|
||||
<xpath expr="//div[hasclass('oe_title')]" position="inside">
|
||||
<field name="hcal_sequence" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record id="virtual_room_view_form" model="ir.ui.view">
|
||||
<field name="model">hotel.room.type</field>
|
||||
<field name="inherit_id" ref="hotel.virtual_room_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="hcal_sequence" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -4,39 +4,39 @@
|
||||
<record id="view_users_form" model="ir.ui.view">
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page/group/group[@name='preferences']" position="before">
|
||||
<group string="Calendar (PMS)" name="calendar">
|
||||
<group colspan="4">
|
||||
<field name="pms_show_notifications" />
|
||||
<field name="pms_show_pricelist" />
|
||||
<field name="pms_show_availability" />
|
||||
<field name="pms_show_num_rooms" />
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<field name="pms_divide_rooms_by_capacity" />
|
||||
<field name="pms_end_day_week" required="True" />
|
||||
<field name="pms_end_day_week_offset" required="True" />
|
||||
<field name="pms_type_move" required="True" />
|
||||
<field name="pms_default_num_days" required="True" />
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<field name="pms_allowed_events_tags" widget="many2many_tags" />
|
||||
<field name="pms_denied_events_tags" widget="many2many_tags" />
|
||||
</group>
|
||||
</group>
|
||||
<group string="Calendar Management (Revenue PMS)" name="calendar">
|
||||
<group colspan="4">
|
||||
<field name="npms_end_day_week" required="True" />
|
||||
<field name="npms_end_day_week_offset" required="True" />
|
||||
<field name="npms_default_num_days" required="True" />
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<field name="npms_allowed_events_tags" widget="many2many_tags" />
|
||||
<field name="npms_denied_events_tags" widget="many2many_tags" />
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page/group/group[@name='preferences']" position="before">
|
||||
<group string="Calendar (PMS)" name="calendar">
|
||||
<group colspan="4">
|
||||
<field name="pms_show_notifications" />
|
||||
<field name="pms_show_pricelist" />
|
||||
<field name="pms_show_availability" />
|
||||
<field name="pms_show_num_rooms" />
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<field name="pms_divide_rooms_by_capacity" />
|
||||
<field name="pms_end_day_week" required="True" />
|
||||
<field name="pms_end_day_week_offset" required="True" />
|
||||
<field name="pms_type_move" required="True" />
|
||||
<field name="pms_default_num_days" required="True" />
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<field name="pms_allowed_events_tags" widget="many2many_tags" />
|
||||
<field name="pms_denied_events_tags" widget="many2many_tags" />
|
||||
</group>
|
||||
</group>
|
||||
<group string="Calendar Management (Revenue PMS)" name="calendar">
|
||||
<group colspan="4">
|
||||
<field name="npms_end_day_week" required="True" />
|
||||
<field name="npms_end_day_week_offset" required="True" />
|
||||
<field name="npms_default_num_days" required="True" />
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<field name="npms_allowed_events_tags" widget="many2many_tags" />
|
||||
<field name="npms_denied_events_tags" widget="many2many_tags" />
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
34
hotel_calendar/views/room_pricelist_cached_views.xml
Normal file
34
hotel_calendar/views/room_pricelist_cached_views.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Form view of hotel room -->
|
||||
<record model="ir.ui.view" id="view_hotel_room_pricelist_cached_form">
|
||||
<field name="name">hotel.room.pricelist.cached.form</field>
|
||||
<field name="model">room.pricelist.cached</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Room Pricelist Cached">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="room_id" />
|
||||
<field name="date" />
|
||||
<field name="price" />
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Tree view of hotel room -->
|
||||
<record model="ir.ui.view" id="view_hotel_room_pricelist_cached_tree">
|
||||
<field name="name">hotel.room.pricelist.cached.tree</field>
|
||||
<field name="model">room.pricelist.cached</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Room Pricelist Cached">
|
||||
<field name="room_id" />
|
||||
<field name="date" />
|
||||
<field name="price" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!--======= Room Type ======= -->
|
||||
<!-- Form view of hotel room type -->
|
||||
<record model="ir.ui.view" id="view_hotel_virtual_room_pricelist_cached_form">
|
||||
<field name="name">hotel.virtual.room.pricelist.cached.form</field>
|
||||
<field name="model">virtual.room.pricelist.cached</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string=" Virtual Room Pricelist Cached">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="virtual_room_id" />
|
||||
<field name="date" />
|
||||
<field name="price" />
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Tree view of hotel room type -->
|
||||
<record model="ir.ui.view" id="view_hotel_virtual_room_pricelist_cached_tree">
|
||||
<field name="name">hotel.virtual.room.pricelist.cached.tree</field>
|
||||
<field name="model">virtual.room.pricelist.cached</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string=" Virtual Room Pricelist Cached">
|
||||
<field name="virtual_room_id" />
|
||||
<field name="date" />
|
||||
<field name="price" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,119 +0,0 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.PMSCalendarModel', function (require) {
|
||||
"use strict";
|
||||
|
||||
var AbstractModel = require('web.AbstractModel'),
|
||||
Context = require('web.Context'),
|
||||
Core = require('web.core'),
|
||||
FieldUtils = require('web.field_utils'),
|
||||
Session = require('web.session');
|
||||
|
||||
|
||||
return AbstractModel.extend({
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this.end_date = null;
|
||||
},
|
||||
|
||||
load: function (params) {
|
||||
this.modelName = params.modelName;
|
||||
this.modelManagementName = 'hotel.calendar.management'
|
||||
},
|
||||
|
||||
save_pricelist: function(params) {
|
||||
return this._rpc({
|
||||
model: this.modelManagementName,
|
||||
method: 'save_changes',
|
||||
args: params,
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
swap_reservations: function(fromIds, toIds) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'swap_reservations',
|
||||
args: [fromIds, toIds],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
get_calendar_data: function(oparams) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'get_hcalendar_all_data',
|
||||
args: oparams,
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
get_hcalendar_settings: function() {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'get_hcalendar_settings',
|
||||
args: [false],
|
||||
});
|
||||
},
|
||||
|
||||
get_room_types: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.room.type',
|
||||
method: 'search_read',
|
||||
args: [false, ['cat_id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
get_floors: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.floor',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
get_amenities: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.room.amenities',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
get_vrooms: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.room.type',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
search_count: function(domain) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'search_count',
|
||||
args: [domain],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
update_records: function(ids, vals) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'write',
|
||||
args: [ids, write_values],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
folio_search_count: function(domain) {
|
||||
return this._rpc({
|
||||
model: 'hotel.folio',
|
||||
method: 'search_count',
|
||||
args: [domain],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Backend stuff -->
|
||||
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<link rel="stylesheet" href="/hotel_calendar_wubook/static/src/css/view.css" />
|
||||
<script type="text/javascript" src="/hotel_calendar_wubook/static/src/js/hotel_calendar_view.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
<!-- Backend stuff -->
|
||||
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<link rel="stylesheet" href="/hotel_calendar_channel_connector/static/src/css/view.css" />
|
||||
<script type="text/javascript" src="/hotel_calendar_channel_connector/static/src/js/views/hotel_calendar_controller.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar_channel_connector/static/src/js/views/hotel_calendar_renderer.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -16,7 +16,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
_usage = 'channel.importer'
|
||||
|
||||
@api.model
|
||||
def _get_room_values_availability(self, vroom_id, date_str, day_vals, set_wmax_avail):
|
||||
def _get_room_values_availability(self, vroom_id, date_str, day_vals, set_max_avail):
|
||||
virtual_room_avail_obj = self.env['hotel.virtual.room.availability']
|
||||
vroom_avail = virtual_room_avail_obj.search([
|
||||
('virtual_room_id', '=', vroom_id),
|
||||
@@ -89,7 +89,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
}).create(vals)
|
||||
|
||||
@api.model
|
||||
def _generate_room_values(self, dfrom, dto, values, set_wmax_avail=False):
|
||||
def _generate_room_values(self, dfrom, dto, values, set_max_avail=False):
|
||||
virtual_room_restr_obj = self.env['hotel.virtual.room.restriction']
|
||||
hotel_virtual_room_obj = self.env['hotel.room.type']
|
||||
def_restr_plan = virtual_room_restr_obj.search([('wpid', '=', '0')])
|
||||
@@ -109,7 +109,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
vroom.id,
|
||||
date_str,
|
||||
day_vals,
|
||||
set_wmax_avail)
|
||||
set_max_avail)
|
||||
if def_restr_plan:
|
||||
self._get_room_values_restrictions(
|
||||
def_restr_plan.id,
|
||||
@@ -696,7 +696,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
|
||||
@api.model
|
||||
def fetch_rooms_values(self, dfrom, dto, rooms=False,
|
||||
set_wmax_avail=False):
|
||||
set_max_avail=False):
|
||||
# Sanitize Dates
|
||||
now_dt = date_utils.now()
|
||||
dfrom_dt = date_utils.get_datetime(dfrom)
|
||||
@@ -715,8 +715,8 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
dfrom_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
||||
dto_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
||||
rooms)
|
||||
self.generate_room_values(dfrom, dto, results,
|
||||
set_wmax_avail=set_wmax_avail)
|
||||
self._generate_room_values(dfrom, dto, results,
|
||||
set_max_avail=set_max_avail)
|
||||
except ValidationError:
|
||||
self.create_issue('room', _("Can't fetch rooms values from WuBook"),
|
||||
results, dfrom=dfrom, dto=dto)
|
||||
|
||||
@@ -29,17 +29,15 @@ class ImportAvailabilityWizard(models.TransientModel):
|
||||
|
||||
date_start = fields.Datetime('Start Date', required=True)
|
||||
date_end = fields.Datetime('End Date', required=True)
|
||||
set_wmax_avail = fields.Boolean('Set wmax_avail?', default=True)
|
||||
set_max_avail = fields.Boolean('Set max avail?', default=True)
|
||||
|
||||
@api.multi
|
||||
def import_availability(self):
|
||||
for record in self:
|
||||
date_start_dt = fields.Datetime.from_string(record.date_start)
|
||||
date_end_dt = fields.Datetime.from_string(record.date_end)
|
||||
wres = self.env['wubook'].fetch_rooms_values(
|
||||
date_start_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
||||
date_end_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
||||
set_wmax_avail=record.set_wmax_avail)
|
||||
record.date_start,
|
||||
record.date_end,
|
||||
set_max_avail=record.set_max_avail)
|
||||
if not wres:
|
||||
raise ValidationError(_("Can't fetch availability from WuBook"))
|
||||
return True
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user