[WIP][MIG][11.0] Hotel Improvements + Hotel Calendar

This commit is contained in:
QS5ELkMu
2018-09-06 00:06:37 +02:00
parent 0c7b3edd77
commit 52562f7341
70 changed files with 509 additions and 533 deletions

View File

@@ -50,9 +50,9 @@
'views/reservation_restriction_views.xml', 'views/reservation_restriction_views.xml',
'views/reservation_restriction_item_views.xml', 'views/reservation_restriction_item_views.xml',
'views/hotel_reservation.xml', 'views/hotel_reservation.xml',
# 'views/virtual_room_views.xml', # 'views/room_type_views.xml',
'views/cardex.xml', 'views/cardex.xml',
'views/virtual_room_availability.xml', 'views/room_type_availability.xml',
# 'views/hotel_dashboard.xml', # 'views/hotel_dashboard.xml',
'data/cron_jobs.xml', 'data/cron_jobs.xml',
'data/records.xml', 'data/records.xml',

View File

@@ -164,7 +164,7 @@
% endif % endif
<br /> <br />
% for rline in object.get_grouped_reservations_json('cancelled'): % for rline in object.get_grouped_reservations_json('cancelled'):
<strong>${rline['num']} x ${rline['virtual_room']['name']} <strong>${rline['num']} x ${rline['room_type']['name']}
% if rline['childrens'] > 0: % if rline['childrens'] > 0:
(${rline['adults']} Adults + ${rline['childrens']} Childrens) (${rline['adults']} Adults + ${rline['childrens']} Childrens)
% else: % else:

View File

@@ -257,7 +257,7 @@
<br /> <br />
% for rline in object.get_grouped_reservations_json('confirm'): % for rline in object.get_grouped_reservations_json('confirm'):
<strong>${rline['num']} x ${rline['virtual_room']['name']} <strong>${rline['num']} x ${rline['room_type']['name']}
% if rline['childrens'] > 0: % if rline['childrens'] > 0:
(${rline['adults']} Adultos + ${rline['childrens']} Niños) (${rline['adults']} Adultos + ${rline['childrens']} Niños)
% else: % else:
@@ -406,13 +406,13 @@
<tr> <tr>
<td class="h2" style="font-family: sans-serif; font-size: 18px; font-weight: bold; color: #C50967; padding: 0 0 0 0; text-transform: uppercase; letter-spacing: 0.5px;">Información de la habitación</td> <td class="h2" style="font-family: sans-serif; font-size: 18px; font-weight: bold; color: #C50967; padding: 0 0 0 0; text-transform: uppercase; letter-spacing: 0.5px;">Información de la habitación</td>
</tr> </tr>
% set vroom_ids = object.room_lines.filtered('to_send').mapped('virtual_room_id.id') % set room_type_ids = object.room_lines.filtered('to_send').mapped('room_type_id.id')
% set vrooms = user.env['hotel.virtual.room'].browse(vroom_ids) % set room_types = user.env['hotel.room.type'].browse(room_type_ids)
% for vroom in vrooms: % for room_type in room_types:
<tr> <tr>
% if vroom.name: % if room_type.name:
<td align="justify" class="subheading" style="color: #555555"> <td align="justify" class="subheading" style="color: #555555">
<strong>${vroom.name}</strong> <strong>${room_type.name}</strong>
</td> </td>
% else: % else:
<td align="justify" class="subheading" style="color: #555555"> <td align="justify" class="subheading" style="color: #555555">

View File

@@ -19,7 +19,7 @@ from . import inherit_account_invoice
# from . import inherit_product_category # from . import inherit_product_category
from . import inherit_product_product from . import inherit_product_product
from . import inherit_res_company from . import inherit_res_company
# from . import virtual_room # from . import room_type
from . import inherit_account_payment from . import inherit_account_payment
from . import hotel_room_type_restriction from . import hotel_room_type_restriction
from . import hotel_room_type_restriction_item from . import hotel_room_type_restriction_item

View File

@@ -10,7 +10,6 @@ from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
class CurrencyExchangeRate(models.Model): class CurrencyExchangeRate(models.Model):
_name = "currency.exchange" _name = "currency.exchange"
_description = "currency" _description = "currency"

View File

@@ -21,6 +21,10 @@ from odoo.addons import decimal_precision as dp
class HotelFolio(models.Model): class HotelFolio(models.Model):
_name = 'hotel.folio'
_description = 'Hotel Folio'
_inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']
_order = 'id'
# @api.depends('invoice_lines.invoice_id.state', 'invoice_lines.quantity') # @api.depends('invoice_lines.invoice_id.state', 'invoice_lines.quantity')
def _get_invoice_qty(self): def _get_invoice_qty(self):
@@ -41,12 +45,6 @@ class HotelFolio(models.Model):
def _amount_all(self): def _amount_all(self):
pass pass
_name = 'hotel.folio'
_description = 'Hotel Folio'
_order = 'id'
_inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']
name = fields.Char('Folio Number', readonly=True, index=True, name = fields.Char('Folio Number', readonly=True, index=True,
default=lambda self: _('New')) default=lambda self: _('New'))
partner_id = fields.Many2one('res.partner', partner_id = fields.Many2one('res.partner',

View File

@@ -16,6 +16,10 @@ _logger = logging.getLogger(__name__)
class HotelReservation(models.Model): class HotelReservation(models.Model):
_name = 'hotel.reservation'
_description = 'Hotel Reservation'
_inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']
_order = "last_updated_res desc, name"
def _get_default_checkin(self): def _get_default_checkin(self):
folio = False folio = False
@@ -110,11 +114,6 @@ class HotelReservation(models.Model):
fields.Date.from_string(res.checkout) - fields.Date.from_string(res.checkin) fields.Date.from_string(res.checkout) - fields.Date.from_string(res.checkin)
).days ).days
_name = 'hotel.reservation'
_description = 'Hotel Reservation'
_inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']
_order = "last_updated_res desc, name"
name = fields.Text('Reservation Description', required=True) name = fields.Text('Reservation Description', required=True)
room_id = fields.Many2one('hotel.room', string='Room') room_id = fields.Many2one('hotel.room', string='Room')
@@ -312,9 +311,12 @@ class HotelReservation(models.Model):
}) })
for record in self: for record in self:
if record.compute_price_out_vals(vals): if record.compute_price_out_vals(vals):
checkin = vals['checkin'] if 'checkin' in vals else record.checkin
checkout = vals['checkout'] if 'checkout' in vals else record.checkout
days_diff = ( days_diff = (
fields.Date.from_string(record.checkout) - \ fields.Date.from_string(checkout) - \
fields.Date.from_string(record.checkin) fields.Date.from_string(checkin)
).days ).days
record.update(record.prepare_reservation_lines( record.update(record.prepare_reservation_lines(
vals['checkin'], vals['checkin'],
@@ -390,7 +392,7 @@ class HotelReservation(models.Model):
'overbooking': self.overbooking, 'overbooking': self.overbooking,
'price_unit': self.price_unit, 'price_unit': self.price_unit,
'splitted': self.splitted, 'splitted': self.splitted,
# 'virtual_room_id': self.virtual_room_id.id, # 'room_type_id': self.room_type_id.id,
'room_type_id': self.room_type_id.id, 'room_type_id': self.room_type_id.id,
} }
@@ -419,7 +421,7 @@ class HotelReservation(models.Model):
#Si el registro no existe, modificar room_type aunque ya esté establecido #Si el registro no existe, modificar room_type aunque ya esté establecido
if not self.room_type_id: if not self.room_type_id:
write_vals.update({'room_type_id': self.room_id.room_type_id.id}) write_vals.update({'room_type_id': self.room_id.room_type_id.id})
self.write(write_vals) self.update(write_vals)
@api.onchange('partner_id') @api.onchange('partner_id')
def onchange_partner_id(self): def onchange_partner_id(self):

View File

@@ -7,6 +7,7 @@ from odoo import models, fields, api, _
class HotelRoomAmenities(models.Model): class HotelRoomAmenities(models.Model):
_name = 'hotel.room.amenities' _name = 'hotel.room.amenities'
_description = 'Room amenities' _description = 'Room amenities'
# The record's name # The record's name
name = fields.Char('Amenity Name', required=True) name = fields.Char('Amenity Name', required=True)
# Used for activate records # Used for activate records

View File

@@ -7,6 +7,7 @@ from odoo import models, fields, api, _
class HotelRoomAmenitiesType(models.Model): class HotelRoomAmenitiesType(models.Model):
_name = 'hotel.room.amenities.type' _name = 'hotel.room.amenities.type'
_description = 'Amenities Type' _description = 'Amenities Type'
# The record's name # The record's name
name = fields.Char('Amenity Name', required=True) name = fields.Char('Amenity Name', required=True)
# Used for activate records # Used for activate records

View File

@@ -10,8 +10,8 @@ class HotelRoomType(models.Model):
""" """
_name = "hotel.room.type" _name = "hotel.room.type"
_description = "Room Type" _description = "Room Type"
_inherits = {'product.product': 'product_id'} _inherits = {'product.product': 'product_id'}
# Relationship between models # Relationship between models
product_id = fields.Many2one('product.product', 'Product Room Type', product_id = fields.Many2one('product.product', 'Product Room Type',
required=True, delegate=True, required=True, delegate=True,
@@ -59,7 +59,7 @@ class HotelRoomType(models.Model):
@api.model @api.model
# TODO Rename to check_availability_room_type # TODO Rename to check_availability_room_type
def check_availability_virtual_room(self, dfrom, dto, def check_availability_room(self, dfrom, dto,
room_type_id=False, notthis=[]): room_type_id=False, notthis=[]):
""" """
Check the avalability for an specific type of room Check the avalability for an specific type of room

View File

@@ -10,7 +10,7 @@ class HotelRoomTypeAvailability(models.Model):
_inherit = 'mail.thread' _inherit = 'mail.thread'
_name = 'hotel.room.type.availability' _name = 'hotel.room.type.availability'
# virtual_room_id = fields.Many2one('hotel.virtual.room', 'Virtual Room', # room_type_id = fields.Many2one('hotel.virtual.room', 'Virtual Room',
# required=True, track_visibility='always', # required=True, track_visibility='always',
# ondelete='cascade') # ondelete='cascade')
room_type_id = fields.Many2one('hotel.room.type', 'Room Type', room_type_id = fields.Many2one('hotel.room.type', 'Room Type',
@@ -34,7 +34,7 @@ class HotelRoomTypeAvailability(models.Model):
self.avail = 0 self.avail = 0
room_type_obj = self.env['hotel.room.type'] room_type_obj = self.env['hotel.room.type']
cavail = len(room_type_obj.check_availability_virtual_room( cavail = len(room_type_obj.check_availability_room(
self.date, self.date,
self.date, self.date,
room_type_id=self.room_type_id.id)) room_type_id=self.room_type_id.id))
@@ -44,7 +44,7 @@ class HotelRoomTypeAvailability(models.Model):
self.avail = max_avail self.avail = max_avail
@api.constrains('date', 'room_type_id') @api.constrains('date', 'room_type_id')
def _check_date_virtual_room_id(self): def _check_date_room_type_id(self):
count = self.search_count([ count = self.search_count([
('date', '=', self.date), ('date', '=', self.date),
('room_type_id', '=', self.room_type_id.id) ('room_type_id', '=', self.room_type_id.id)

View File

@@ -13,7 +13,7 @@ class HotelRoomTypeRestrictionItem(models.Model):
restriction_id = fields.Many2one('hotel.room.type.restriction', restriction_id = fields.Many2one('hotel.room.type.restriction',
'Restriction Plan', ondelete='cascade', 'Restriction Plan', ondelete='cascade',
index=True) index=True)
# virtual_room_id = fields.Many2one('hotel.virtual.room', 'Virtual Room', # room_type_id = fields.Many2one('hotel.virtual.room', 'Virtual Room',
# required=True, ondelete='cascade') # required=True, ondelete='cascade')
room_type_id = fields.Many2one('hotel.room.type', 'Room Type', room_type_id = fields.Many2one('hotel.room.type', 'Room Type',
required=True, ondelete='cascade') required=True, ondelete='cascade')
@@ -21,8 +21,8 @@ class HotelRoomTypeRestrictionItem(models.Model):
date_end = fields.Date("To") date_end = fields.Date("To")
applied_on = fields.Selection([ applied_on = fields.Selection([
('1_global', 'Global'), ('1_global', 'Global'),
# ('0_virtual_room', 'Virtual Room')], string="Apply On", required=True, # ('0_room_type', 'Virtual Room')], string="Apply On", required=True,
# default='0_virtual_room', # default='0_room_type',
('0_room_type', 'Room Type')], string="Apply On", required=True, ('0_room_type', 'Room Type')], string="Apply On", required=True,
default='0_room_type', default='0_room_type',
help='Pricelist Item applicable on selected option') help='Pricelist Item applicable on selected option')

View File

@@ -8,7 +8,9 @@ from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class HotelService(models.Model): class HotelService(models.Model):
_name = 'hotel.service'
_description = 'Hotel Services and its charges'
@api.model @api.model
def _service_checkin(self): def _service_checkin(self):
if 'checkin' in self._context: if 'checkin' in self._context:
@@ -30,9 +32,6 @@ class HotelService(models.Model):
], limit=1) ], limit=1)
return False return False
_name = 'hotel.service'
_description = 'Hotel Services and its charges'
name = fields.Char('Service description') name = fields.Char('Service description')
# services in the hotel are products # services in the hotel are products
product_id = fields.Many2one('product.product', 'Service', required=True) product_id = fields.Many2one('product.product', 'Service', required=True)

View File

@@ -146,7 +146,7 @@ class HotelServiceLine(models.Model):
'product_uom': self.product_id.uom_id, 'product_uom': self.product_id.uom_id,
'price_unit': self.product_id.price, 'price_unit': self.product_id.price,
}) })
self.write(write_vals) self.update(write_vals)
#~ self.price_unit = tax_obj._fix_tax_included_price(prod.price, #~ self.price_unit = tax_obj._fix_tax_included_price(prod.price,
#~ prod.taxes_id, #~ prod.taxes_id,

View File

@@ -7,7 +7,6 @@ _logger = logging.getLogger(__name__)
class AccountPayment(models.Model): class AccountPayment(models.Model):
_inherit = 'account.payment' _inherit = 'account.payment'
folio_id = fields.Many2one('hotel.folio', string='Folio') folio_id = fields.Many2one('hotel.folio', string='Folio')

View File

@@ -20,12 +20,12 @@ access_hotel_order_call,hotel.order.call,sale.model_sale_order,hotel.group_hotel
access_hotel_order_line_call,hotel.order.line.call,sale.model_sale_order_line,hotel.group_hotel_call,1,1,1,1 access_hotel_order_line_call,hotel.order.line.call,sale.model_sale_order_line,hotel.group_hotel_call,1,1,1,1
access_hotel_order_line_user,hotel.order.line.user,sale.model_sale_order_line,hotel.group_hotel_user,1,1,1,1 access_hotel_order_line_user,hotel.order.line.user,sale.model_sale_order_line,hotel.group_hotel_user,1,1,1,1
access_hotel_order_user,hotel.order.user,sale.model_sale_order,hotel.group_hotel_user,1,1,1,1 access_hotel_order_user,hotel.order.user,sale.model_sale_order,hotel.group_hotel_user,1,1,1,1
access_hotel_restrictions_call,hotel.restriction. All,hotel.model_hotel_virtual_room_restriction,hotel.group_hotel_call,1,0,0,0 access_hotel_restrictions_call,hotel.restriction. All,hotel.model_hotel_room_type_restriction,hotel.group_hotel_call,1,0,0,0
access_hotel_restrictions_item_call,hotel.restriction.item.call,hotel.model_hotel_virtual_room_restriction_item,hotel.group_hotel_call,1,0,0,0 access_hotel_restrictions_item_call,hotel.restriction.item.call,hotel.model_hotel_room_type_restriction_item,hotel.group_hotel_call,1,0,0,0
access_hotel_restrictions_item_manager,hotel.restriction.item.manager,hotel.model_hotel_virtual_room_restriction_item,hotel.group_hotel_manager,1,1,1,1 access_hotel_restrictions_item_manager,hotel.restriction.item.manager,hotel.model_hotel_room_type_restriction_item,hotel.group_hotel_manager,1,1,1,1
access_hotel_restrictions_item_user,hotel.restriction.item.user,hotel.model_hotel_virtual_room_restriction_item,hotel.group_hotel_user,1,0,0,0 access_hotel_restrictions_item_user,hotel.restriction.item.user,hotel.model_hotel_room_type_restriction_item,hotel.group_hotel_user,1,0,0,0
access_hotel_restrictions_manager,hotel.restriction.manager,hotel.model_hotel_virtual_room_restriction,hotel.group_hotel_manager,1,1,1,1 access_hotel_restrictions_manager,hotel.restriction.manager,hotel.model_hotel_room_type_restriction,hotel.group_hotel_manager,1,1,1,1
access_hotel_restrictions_user,hotel.restriction.user,hotel.model_hotel_virtual_room_restriction,hotel.group_hotel_user,1,0,0,0 access_hotel_restrictions_user,hotel.restriction.user,hotel.model_hotel_room_type_restriction,hotel.group_hotel_user,1,0,0,0
access_hotel_room,hotel.room.user,model_hotel_room,hotel.group_hotel_user,1,0,0,0 access_hotel_room,hotel.room.user,model_hotel_room,hotel.group_hotel_user,1,0,0,0
access_hotel_room_amenities,hotel.room_aminities.user,model_hotel_room_amenities,hotel.group_hotel_user,1,0,0,0 access_hotel_room_amenities,hotel.room_aminities.user,model_hotel_room_amenities,hotel.group_hotel_user,1,0,0,0
access_hotel_room_amenities_call,hotel.room_aminities.call,model_hotel_room_amenities,hotel.group_hotel_call,1,0,0,0 access_hotel_room_amenities_call,hotel.room_aminities.call,model_hotel_room_amenities,hotel.group_hotel_call,1,0,0,0
@@ -43,9 +43,9 @@ access_hotel_service_call,hotel_service.call,model_hotel_service,hotel.group_hot
access_hotel_user reconcilie,hotel.user reconcilie,account.model_account_partial_reconcile,hotel.group_hotel_user,1,1,1,1 access_hotel_user reconcilie,hotel.user reconcilie,account.model_account_partial_reconcile,hotel.group_hotel_user,1,1,1,1
access_hotel_user_account_full_reconcilie,hotel.user_account_full_reconcilie,account.model_account_full_reconcile,hotel.group_hotel_user,1,1,1,1 access_hotel_user_account_full_reconcilie,hotel.user_account_full_reconcilie,account.model_account_full_reconcile,hotel.group_hotel_user,1,1,1,1
access_hotel_user_user,hotel.user_res_user,auth_crypt.model_res_users,hotel.group_hotel_user,1,1,0,0 access_hotel_user_user,hotel.user_res_user,auth_crypt.model_res_users,hotel.group_hotel_user,1,1,0,0
access_hotel_virtual_room_availability_call,hotel.availability.call,hotel.model_hotel_virtual_room_availability,hotel.group_hotel_call,1,1,1,1 access_hotel_room_type_availability_call,hotel.availability.call,hotel.model_hotel_room_type_availability,hotel.group_hotel_call,1,1,1,1
access_hotel_virtual_room_availability_manager,hotel.availability.manager,hotel.model_hotel_virtual_room_availability,hotel.group_hotel_manager,1,1,1,1 access_hotel_room_type_availability_manager,hotel.availability.manager,hotel.model_hotel_room_type_availability,hotel.group_hotel_manager,1,1,1,1
access_hotel_virtual_room_availability_user,hotel.availability.user,hotel.model_hotel_virtual_room_availability,hotel.group_hotel_user,1,1,1,1 access_hotel_room_type_availability_user,hotel.availability.user,hotel.model_hotel_room_type_availability,hotel.group_hotel_user,1,1,1,1
access_product_category,product.category.user,product.model_product_category,hotel.group_hotel_user,1,0,0,0 access_product_category,product.category.user,product.model_product_category,hotel.group_hotel_user,1,0,0,0
access_product_category_call,product.category.call,product.model_product_category,hotel.group_hotel_call,1,0,0,0 access_product_category_call,product.category.call,product.model_product_category,hotel.group_hotel_call,1,0,0,0
access_product_category_manager,product.category.manager,product.model_product_category,hotel.group_hotel_manager,1,1,1,1 access_product_category_manager,product.category.manager,product.model_product_category,hotel.group_hotel_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
20 access_hotel_order_line_call hotel.order.line.call sale.model_sale_order_line hotel.group_hotel_call 1 1 1 1
21 access_hotel_order_line_user hotel.order.line.user sale.model_sale_order_line hotel.group_hotel_user 1 1 1 1
22 access_hotel_order_user hotel.order.user sale.model_sale_order hotel.group_hotel_user 1 1 1 1
23 access_hotel_restrictions_call hotel.restriction. All hotel.model_hotel_virtual_room_restriction hotel.model_hotel_room_type_restriction hotel.group_hotel_call 1 0 0 0
24 access_hotel_restrictions_item_call hotel.restriction.item.call hotel.model_hotel_virtual_room_restriction_item hotel.model_hotel_room_type_restriction_item hotel.group_hotel_call 1 0 0 0
25 access_hotel_restrictions_item_manager hotel.restriction.item.manager hotel.model_hotel_virtual_room_restriction_item hotel.model_hotel_room_type_restriction_item hotel.group_hotel_manager 1 1 1 1
26 access_hotel_restrictions_item_user hotel.restriction.item.user hotel.model_hotel_virtual_room_restriction_item hotel.model_hotel_room_type_restriction_item hotel.group_hotel_user 1 0 0 0
27 access_hotel_restrictions_manager hotel.restriction.manager hotel.model_hotel_virtual_room_restriction hotel.model_hotel_room_type_restriction hotel.group_hotel_manager 1 1 1 1
28 access_hotel_restrictions_user hotel.restriction.user hotel.model_hotel_virtual_room_restriction hotel.model_hotel_room_type_restriction hotel.group_hotel_user 1 0 0 0
29 access_hotel_room hotel.room.user model_hotel_room hotel.group_hotel_user 1 0 0 0
30 access_hotel_room_amenities hotel.room_aminities.user model_hotel_room_amenities hotel.group_hotel_user 1 0 0 0
31 access_hotel_room_amenities_call hotel.room_aminities.call model_hotel_room_amenities hotel.group_hotel_call 1 0 0 0
43 access_hotel_user reconcilie hotel.user reconcilie account.model_account_partial_reconcile hotel.group_hotel_user 1 1 1 1
44 access_hotel_user_account_full_reconcilie hotel.user_account_full_reconcilie account.model_account_full_reconcile hotel.group_hotel_user 1 1 1 1
45 access_hotel_user_user hotel.user_res_user auth_crypt.model_res_users hotel.group_hotel_user 1 1 0 0
46 access_hotel_virtual_room_availability_call access_hotel_room_type_availability_call hotel.availability.call hotel.model_hotel_virtual_room_availability hotel.model_hotel_room_type_availability hotel.group_hotel_call 1 1 1 1
47 access_hotel_virtual_room_availability_manager access_hotel_room_type_availability_manager hotel.availability.manager hotel.model_hotel_virtual_room_availability hotel.model_hotel_room_type_availability hotel.group_hotel_manager 1 1 1 1
48 access_hotel_virtual_room_availability_user access_hotel_room_type_availability_user hotel.availability.user hotel.model_hotel_virtual_room_availability hotel.model_hotel_room_type_availability hotel.group_hotel_user 1 1 1 1
49 access_product_category product.category.user product.model_product_category hotel.group_hotel_user 1 0 0 0
50 access_product_category_call product.category.call product.model_product_category hotel.group_hotel_call 1 0 0 0
51 access_product_category_manager product.category.manager product.model_product_category hotel.group_hotel_manager 1 1 1 1

View File

@@ -59,7 +59,7 @@ class TestHotel(TestMail):
'checkin': checkin.strftime(DEFAULT_SERVER_DATETIME_FORMAT), 'checkin': checkin.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'checkout': checkout.strftime(DEFAULT_SERVER_DATETIME_FORMAT), 'checkout': checkout.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'folio_id': folio.id, 'folio_id': folio.id,
'virtual_room_id': room.price_virtual_room.id, 'room_type_id': room.price_room_type.id,
'product_id': room.product_id.id, 'product_id': room.product_id.id,
}) })
self.assertTrue( self.assertTrue(
@@ -171,14 +171,14 @@ class TestHotel(TestMail):
cls.hotel_room_simple_100 = Rooms.create({ cls.hotel_room_simple_100 = Rooms.create({
'name': '100', 'name': '100',
'sale_price_type': 'vroom', 'sale_price_type': 'vroom',
'price_virtual_room': cls.hotel_vroom_budget.id, 'price_room_type': cls.hotel_vroom_budget.id,
'categ_id': cls.hotel_room_type_simple.cat_id.id, 'categ_id': cls.hotel_room_type_simple.cat_id.id,
'capacity': 1, 'capacity': 1,
}) })
cls.hotel_room_simple_101 = Rooms.create({ cls.hotel_room_simple_101 = Rooms.create({
'name': '101', 'name': '101',
'sale_price_type': 'vroom', 'sale_price_type': 'vroom',
'price_virtual_room': cls.hotel_vroom_budget.id, 'price_room_type': cls.hotel_vroom_budget.id,
'categ_id': cls.hotel_room_type_simple.cat_id.id, 'categ_id': cls.hotel_room_type_simple.cat_id.id,
'capacity': 1, 'capacity': 1,
'sequence': 1, 'sequence': 1,
@@ -186,7 +186,7 @@ class TestHotel(TestMail):
cls.hotel_room_double_200 = Rooms.create({ cls.hotel_room_double_200 = Rooms.create({
'name': '200', 'name': '200',
'sale_price_type': 'vroom', 'sale_price_type': 'vroom',
'price_virtual_room': cls.hotel_vroom_special.id, 'price_room_type': cls.hotel_vroom_special.id,
'categ_id': cls.hotel_room_type_double.cat_id.id, 'categ_id': cls.hotel_room_type_double.cat_id.id,
'capacity': 2, 'capacity': 2,
}) })
@@ -228,16 +228,16 @@ class TestHotel(TestMail):
for i in range(0, len(v_vr)): for i in range(0, len(v_vr)):
ndate = now_utc_dt + timedelta(days=i) ndate = now_utc_dt + timedelta(days=i)
vroom_avail_obj.create({ vroom_avail_obj.create({
'virtual_room_id': k_vr, 'room_type_id': k_vr,
'avail': v_vr[i], 'avail': v_vr[i],
'date': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT) 'date': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
}) })
vroom_rest_item_obj.create({ vroom_rest_item_obj.create({
'virtual_room_id': k_vr, 'room_type_id': k_vr,
'restriction_id': cls.parity_restrictions_id, 'restriction_id': cls.parity_restrictions_id,
'date_start': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT), 'date_start': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT),
'date_end': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT), 'date_end': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT),
'applied_on': '0_virtual_room', 'applied_on': '0_room_type',
'min_stay': cls.restrictions_min_stay_tmp[k_vr][i], 'min_stay': cls.restrictions_min_stay_tmp[k_vr][i],
}) })
pricelist_item_obj.create({ pricelist_item_obj.create({

View File

@@ -232,7 +232,7 @@ class TestHotelReservations(TestHotel):
# 5.0, 15.0, 15.0, 35.0, 35.0, 10.0, 10.0 # 5.0, 15.0, 15.0, 35.0, 35.0, 10.0, 10.0
vroom_prices = self.prices_tmp[self.hotel_room_double_200.price_virtual_room.id] vroom_prices = self.prices_tmp[self.hotel_room_double_200.price_room_type.id]
org_reserv_start_utc_dt = now_utc_dt + timedelta(days=1) org_reserv_start_utc_dt = now_utc_dt + timedelta(days=1)
org_reserv_end_utc_dt = org_reserv_start_utc_dt + timedelta(days=2) org_reserv_end_utc_dt = org_reserv_start_utc_dt + timedelta(days=2)
folio = self.create_folio(self.user_hotel_manager, self.partner_2) folio = self.create_folio(self.user_hotel_manager, self.partner_2)

View File

@@ -194,7 +194,7 @@
<field name="partner_id"/> <field name="partner_id"/>
<field name="splitted" invisible="1" /> <field name="splitted" invisible="1" />
<field name="parent_reservation" invisible="1" /> <field name="parent_reservation" invisible="1" />
<!-- <field name="virtual_room_id" string="Reserved Room Type"/> --> <!-- <field name="room_type_id" string="Reserved Room Type"/> -->
<field name="room_type_id" string="Reserved Room Type"/> <field name="room_type_id" string="Reserved Room Type"/>
<field name="nights" /> <field name="nights" />
<field name="adults" string="Persons"/> <field name="adults" string="Persons"/>
@@ -307,7 +307,7 @@
<field name="name"/> <field name="name"/>
<field name="adults"/> <field name="adults"/>
<field name="children"/> <field name="children"/>
<!-- <field name="virtual_room_id" on_change="1" options="{'no_create': True,'no_open': True}" <!-- <field name="room_type_id" on_change="1" options="{'no_create': True,'no_open': True}"
attrs="{'readonly':[('state','not in',('draft'))]}"/> --> attrs="{'readonly':[('state','not in',('draft'))]}"/> -->
<field name="channel_type" attrs="{'required':[('reservation_type','not in',('staff','out'))]}"/> <field name="channel_type" attrs="{'required':[('reservation_type','not in',('staff','out'))]}"/>
</group> </group>

View File

@@ -186,7 +186,7 @@
<field name="name"/> <field name="name"/>
<field name="adults"/> <field name="adults"/>
<field name="children"/> <field name="children"/>
<!-- <field name="virtual_room_id" on_change="1" options="{'no_create': True,'no_open': True}" <!-- <field name="room_type_id" on_change="1" options="{'no_create': True,'no_open': True}"
attrs="{'readonly':[('state','not in',('draft'))]}"/> --> attrs="{'readonly':[('state','not in',('draft'))]}"/> -->
<field name="room_type_id" on_change="1" options="{'no_create': True,'no_open': True}" <field name="room_type_id" on_change="1" options="{'no_create': True,'no_open': True}"
attrs="{'readonly':[('state','not in',('draft'))]}"/> attrs="{'readonly':[('state','not in',('draft'))]}"/>
@@ -335,7 +335,7 @@
/> />
<field name="partner_id"/> <field name="partner_id"/>
<field name="parent_reservation" invisible="1" /> <field name="parent_reservation" invisible="1" />
<!-- <field name="virtual_room_id" string="Reserved Room Type"/> --> <!-- <field name="room_type_id" string="Reserved Room Type"/> -->
<field name="room_type_id" string="Reserved Unit Type" /> <field name="room_type_id" string="Reserved Unit Type" />
<field name="nights" /> <field name="nights" />
<field name="adults" string="Persons"/> <field name="adults" string="Persons"/>
@@ -432,7 +432,7 @@
/> />
<group expand="0" string="Group By"> <group expand="0" string="Group By">
<!-- <filter string="Room Type" domain="[]" <!-- <filter string="Room Type" domain="[]"
context="{'group_by':'virtual_room_id'}"/> --> context="{'group_by':'room_type_id'}"/> -->
<filter string="Room Type" domain="[]" <filter string="Room Type" domain="[]"
context="{'group_by':'room_type_id'}"/> context="{'group_by':'room_type_id'}"/>
<filter string="Creation Date" domain="[]" <filter string="Creation Date" domain="[]"

View File

@@ -38,9 +38,9 @@
</group> </group>
<group> <group>
<!-- <field name="sale_price_type" /> --> <!-- <field name="sale_price_type" /> -->
<!--field name="price_virtual_room_domain" invisible="1" /--> <!--field name="price_room_type_domain" invisible="1" /-->
<!-- <field name="price_virtual_room" domain="[('room_ids.id', '=', active_id)]" attrs="{'invisible':[('sale_price_type', '!=', 'vroom')], 'required': [('sale_price_type', '=', 'vroom')]}" /> --> <!-- <field name="price_room_type" domain="[('room_ids.id', '=', active_id)]" attrs="{'invisible':[('sale_price_type', '!=', 'room_type')], 'required': [('sale_price_type', '=', 'room_type')]}" /> -->
<!-- <field name="price_room_type" domain="[('room_ids.id', '=', active_id)]" attrs="{'invisible':[('sale_price_type', '!=', 'vroom')], 'required': [('sale_price_type', '=', 'vroom')]}" /> --> <!-- <field name="price_room_type" domain="[('room_ids.id', '=', active_id)]" attrs="{'invisible':[('sale_price_type', '!=', 'room_type')], 'required': [('sale_price_type', '=', 'room_type')]}" /> -->
</group> </group>
<newline /> <newline />
<!-- <separator colspan='4' string="Customer Taxes" /> --> <!-- <separator colspan='4' string="Customer Taxes" /> -->

View File

@@ -9,7 +9,7 @@
<form string="Restrictions"> <form string="Restrictions">
<group> <group>
<field name="applied_on" widget="radio"/> <field name="applied_on" widget="radio"/>
<!-- <field name="virtual_room_id" attrs="{'invisible':[['applied_on', '=', '1_global']]}" required="True"/> --> <!-- <field name="room_type_id" attrs="{'invisible':[['applied_on', '=', '1_global']]}" required="True"/> -->
<field name="room_type_id" attrs="{'invisible':[['applied_on', '=', '1_global']]}" required="True"/> <field name="room_type_id" attrs="{'invisible':[['applied_on', '=', '1_global']]}" required="True"/>
</group> </group>
<group> <group>
@@ -43,7 +43,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Restrictions"> <tree string="Restrictions">
<field name="applied_on"/> <field name="applied_on"/>
<!-- <field name="virtual_room_id" attrs="{'invisible':[['applied_on', '=', '1_virtual_room']]}"/> --> <!-- <field name="room_type_id" attrs="{'invisible':[['applied_on', '=', '1_room_type']]}"/> -->
<field name="room_type_id" attrs="{'invisible':[['applied_on', '=', '0_room_type']]}"/> <field name="room_type_id" attrs="{'invisible':[['applied_on', '=', '0_room_type']]}"/>
<field name="date_start"/> <field name="date_start"/>
<field name="date_end"/> <field name="date_end"/>

View File

@@ -19,7 +19,7 @@
<field name="item_ids" nolabel="1"> <field name="item_ids" nolabel="1">
<tree string="Restriction Items"> <tree string="Restriction Items">
<field name="applied_on"/> <field name="applied_on"/>
<!-- <field name="virtual_room_id" attr="{'invisible':[['applied_on', '=', '1_virtual_room']]}"/> --> <!-- <field name="room_type_id" attr="{'invisible':[['applied_on', '=', '1_room_type']]}"/> -->
<field name="room_type_id" attr="{'invisible':[['applied_on', '=', '0_room_type']]}"/> <field name="room_type_id" attr="{'invisible':[['applied_on', '=', '0_room_type']]}"/>
<field name="date_start"/> <field name="date_start"/>
<field name="date_end"/> <field name="date_end"/>

View File

@@ -2,14 +2,14 @@
<odoo> <odoo>
<!-- FORM availability --> <!-- FORM availability -->
<record id="virtual_room_availability_view_form" model="ir.ui.view"> <record id="room_type_availability_view_form" model="ir.ui.view">
<field name="name">hotel.room.type.availability.form</field> <field name="name">hotel.room.type.availability.form</field>
<field name="model">hotel.room.type.availability</field> <field name="model">hotel.room.type.availability</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Availability"> <form string="Availability">
<sheet> <sheet>
<group> <group>
<!-- <h1><field name="virtual_room_id" required="1"/></h1> --> <!-- <h1><field name="room_type_id" required="1"/></h1> -->
<h1><field name="room_type_id" required="1"/></h1> <h1><field name="room_type_id" required="1"/></h1>
</group> </group>
<group> <group>
@@ -28,12 +28,12 @@
</record> </record>
<!-- TREE restriction --> <!-- TREE restriction -->
<record id="virtual_room_availability_view_tree" model="ir.ui.view"> <record id="room_type_availability_view_tree" model="ir.ui.view">
<field name="name">hotel.room.type.availability.tree</field> <field name="name">hotel.room.type.availability.tree</field>
<field name="model">hotel.room.type.availability</field> <field name="model">hotel.room.type.availability</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Restrictions"> <tree string="Restrictions">
<!-- <field name="virtual_room_id" required="1"/> --> <!-- <field name="room_type_id" required="1"/> -->
<field name="room_type_id" required="1"/> <field name="room_type_id" required="1"/>
<field name="date" required="1"/> <field name="date" required="1"/>
<field name="avail"/> <field name="avail"/>
@@ -44,7 +44,7 @@
</record> </record>
<!-- Action of reservation restriction --> <!-- Action of reservation restriction -->
<record model="ir.actions.act_window" id="virtual_room_availability_action"> <record model="ir.actions.act_window" id="room_type_availability_action">
<field name="name">Virtual Room Availability</field> <field name="name">Virtual Room Availability</field>
<field name="res_model">hotel.room.type.availability</field> <field name="res_model">hotel.room.type.availability</field>
<field name="view_type">form</field> <field name="view_type">form</field>
@@ -52,8 +52,8 @@
</record> </record>
<!-- MENUS --> <!-- MENUS -->
<menuitem name="Availability" id="virtual_room_availability_menu" <menuitem name="Availability" id="room_type_availability_menu"
action="virtual_room_availability_action" sequence="22" action="room_type_availability_action" sequence="22"
parent="hotel.configuration_others"/> parent="hotel.configuration_others"/>
</odoo> </odoo>

View File

@@ -2,9 +2,9 @@
<odoo> <odoo>
<!-- FORM Virtual Room --> <!-- FORM Virtual Room -->
<record id="virtual_room_view_form" model="ir.ui.view"> <record id="room_type_view_form" model="ir.ui.view">
<field name="name">virtual.room.view.form</field> <field name="name">room.type.view.form</field>
<field name="model">hotel.virtual.room</field> <field name="model">hotel.room.type</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Virtual Room"> <form string="Virtual Room">
<sheet> <sheet>
@@ -41,9 +41,9 @@
</record> </record>
<!-- TREE Virtual Room --> <!-- TREE Virtual Room -->
<record id="virtual_room_view_tree" model="ir.ui.view"> <record id="room_type_view_tree" model="ir.ui.view">
<field name="name">virtual.room.view.tree</field> <field name="name">room.type.view.tree</field>
<field name="model">hotel.virtual.room</field> <field name="model">hotel.room.type</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Virtual Rooms"> <tree string="Virtual Rooms">
<field name="name"/> <field name="name"/>
@@ -57,16 +57,16 @@
</field> </field>
</record> </record>
<record model="ir.actions.act_window" id="virtual_room_action_form"> <record model="ir.actions.act_window" id="room_type_action_form">
<field name="name">Virtual Rooms</field> <field name="name">Virtual Rooms</field>
<field name="res_model">hotel.virtual.room</field> <field name="res_model">hotel.room.type</field>
<field name="view_type">form</field> <field name="view_type">form</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
</record> </record>
<!-- MENUS --> <!-- MENUS -->
<menuitem name="Virtual rooms" id="virtual_room_menu" <menuitem name="Virtual rooms" id="room_type_menu"
action="virtual_room_action_form" sequence="40" action="room_type_action_form" sequence="40"
parent="hotel.menu_hotel_room"/> parent="hotel.menu_hotel_room"/>
</odoo> </odoo>

View File

@@ -212,7 +212,7 @@ class Wizard(models.TransientModel):
# show the checkin fields if a partner is selected # show the checkin fields if a partner is selected
if self.op_select_partner == 'S' and self.partner_id.id != False: if self.op_select_partner == 'S' and self.partner_id.id != False:
write_vals.update({'checkin_mode': 1}) write_vals.update({'checkin_mode': 1})
self.write(write_vals) self.update(write_vals)
@api.onchange('op_select_partner') @api.onchange('op_select_partner')
def onchange_op_select_partner(self): def onchange_op_select_partner(self):

View File

@@ -32,7 +32,7 @@ class DuplicateReservationWizard(models.TransientModel):
})) }))
# Check Input # Check Input
avails = hotel_room_type_obj.check_availability_virtual_room( avails = hotel_room_type_obj.check_availability_room(
reservation_id.checkin, reservation_id.checkin,
reservation_id.checkout, reservation_id.checkout,
room_type_id=reservation_id.room_type_id.id) room_type_id=reservation_id.room_type_id.id)
@@ -43,10 +43,10 @@ class DuplicateReservationWizard(models.TransientModel):
There are no '%d' free rooms") % self.num) There are no '%d' free rooms") % self.num)
for i in range(0, self.num): for i in range(0, self.num):
free_rooms = hotel_room_type_obj.check_availability_virtual_room( free_rooms = hotel_room_type_obj.check_availability_room(
reservation_id.checkin, reservation_id.checkin,
reservation_id.checkout, reservation_id.checkout,
virtual_room_id=reservation_id.room_type_id.id) room_type_id=reservation_id.room_type_id.id)
if any(free_rooms): if any(free_rooms):
new_reservation_id = hotel_reservation_obj.create({ new_reservation_id = hotel_reservation_obj.create({
'room_id': free_rooms[0].id, 'room_id': free_rooms[0].id,

View File

@@ -30,7 +30,7 @@ class MassiveChangesWizard(models.TransientModel):
('0', 'Global'), ('0', 'Global'),
('1', 'Virtual Room'), ('1', 'Virtual Room'),
], string='Applied On', default='0') ], string='Applied On', default='0')
# virtual_room_ids = fields.Many2many('hotel.virtual.room', # room_type_ids = fields.Many2many('hotel.virtual.room',
# string="Virtual Rooms") # string="Virtual Rooms")
room_type_ids = fields.Many2many('hotel.room.type', room_type_ids = fields.Many2many('hotel.room.type',
string="Room Types") string="Room Types")
@@ -171,7 +171,7 @@ class MassiveChangesWizard(models.TransientModel):
('date_start', '>=', ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)), ('date_start', '>=', ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)),
('date_end', '<=', ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)), ('date_end', '<=', ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)),
('restriction_id', '=', record.restriction_id.id), ('restriction_id', '=', record.restriction_id.id),
('applied_on', '=', '0_virtual_room'), ('applied_on', '=', '0_room_type'),
] ]
for room_type in room_types: for room_type in room_types:
@@ -189,7 +189,7 @@ class MassiveChangesWizard(models.TransientModel):
'date_end': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT), 'date_end': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT),
'restriction_id': record.restriction_id.id, 'restriction_id': record.restriction_id.id,
'room_type_id': room_type.id, 'room_type_id': room_type.id,
'applied_on': '0_virtual_room', 'applied_on': '0_room_type',
}) })
hotel_room_type_re_it_obj.create(vals) hotel_room_type_re_it_obj.create(vals)
@@ -200,7 +200,7 @@ class MassiveChangesWizard(models.TransientModel):
if record.change_no_ota: if record.change_no_ota:
vals.update({'no_ota': record.no_ota}) vals.update({'no_ota': record.no_ota})
if record.change_avail: if record.change_avail:
cavail = len(hotel_room_type_obj.check_availability_virtual_room( cavail = len(hotel_room_type_obj.check_availability_room(
ndate.strftime(DEFAULT_SERVER_DATETIME_FORMAT), ndate.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
ndate.strftime(DEFAULT_SERVER_DATETIME_FORMAT), ndate.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
room_type_id=room_type.id)) room_type_id=room_type.id))

View File

@@ -10,7 +10,7 @@
<group> <group>
<field name="section" required="1" /> <field name="section" required="1" />
<field name="applied_on" required="1" /> <field name="applied_on" required="1" />
<!-- <field name="virtual_room_ids" widget="many2many_tags" attrs="{'invisible':[('applied_on', '!=', '1')], 'required':[('applied_on', '=', '1')]}" /> --> <!-- <field name="room_type_ids" widget="many2many_tags" attrs="{'invisible':[('applied_on', '!=', '1')], 'required':[('applied_on', '=', '1')]}" /> -->
<field name="room_type_ids" widget="many2many_tags" attrs="{'invisible':[('applied_on', '!=', '1')], 'required':[('applied_on', '=', '1')]}" /> <field name="room_type_ids" widget="many2many_tags" attrs="{'invisible':[('applied_on', '!=', '1')], 'required':[('applied_on', '=', '1')]}" />
</group> </group>
<group colspan="8" col="8"> <group colspan="8" col="8">

View File

@@ -64,7 +64,7 @@ class SplitReservationWizard(models.TransientModel):
'splitted': True, 'splitted': True,
'price_unit': tprice[1], 'price_unit': tprice[1],
'parent_reservation': parent_res.id, 'parent_reservation': parent_res.id,
'virtual_room_id': parent_res.virtual_room_id.id, 'room_type_id': parent_res.room_type_id.id,
'discount': parent_res.discount, 'discount': parent_res.discount,
}) })
reservation_copy = self.env['hotel.reservation'].create(vals) reservation_copy = self.env['hotel.reservation'].create(vals)

View File

@@ -9,8 +9,8 @@ from . import hotel_calendar_management
from . import res_config from . import res_config
from . import inherited_hotel_room from . import inherited_hotel_room
from . import inherited_hotel_room_type from . import inherited_hotel_room_type
from . import inherited_hotel_virtual_room_restriction_item from . import inherited_hotel_room_type_restriction_item
from . import inherited_hotel_virtual_room_availability from . import inherited_hotel_room_type_availability
from . import inherited_product_pricelist from . import inherited_product_pricelist
from . import inherited_hotel_folio from . import inherited_hotel_folio
from . import inherited_ir_default from . import inherited_ir_default

View File

@@ -35,11 +35,11 @@ class HotelCalendarManagement(models.TransientModel):
return vals return vals
@api.model @api.model
def _get_availability_values(self, avail, vroom): def _get_availability_values(self, avail, room_type):
vroom_obj = self.env['hotel.room.type'] room_type_obj = self.env['hotel.room.type']
cavail = len(vroom_obj.check_availability_virtual_room( cavail = len(room_type_obj.check_availability_room(
avail['date'], avail['date'], virtual_room_id=vroom.id)) avail['date'], avail['date'], room_type_id=room_type.id))
ravail = min(cavail, vroom.total_rooms_count, int(avail['avail'])) ravail = min(cavail, room_type.total_rooms_count, int(avail['avail']))
vals = { vals = {
'no_ota': avail['no_ota'], 'no_ota': avail['no_ota'],
'avail': ravail, 'avail': ravail,
@@ -49,15 +49,15 @@ class HotelCalendarManagement(models.TransientModel):
@api.multi @api.multi
def save_changes(self, pricelist_id, restriction_id, pricelist, def save_changes(self, pricelist_id, restriction_id, pricelist,
restrictions, availability): restrictions, availability):
vroom_obj = self.env['hotel.room.type'] room_type_obj = self.env['hotel.room.type']
product_pricelist_item_obj = self.env['product.pricelist.item'] product_pricelist_item_obj = self.env['product.pricelist.item']
vroom_rest_item_obj = self.env['hotel.room.type.restriction.item'] room_type_rest_item_obj = self.env['hotel.room.type.restriction.item']
vroom_avail_obj = self.env['hotel.room.type.availability'] room_type_avail_obj = self.env['hotel.room.type.availability']
# Save Pricelist # Save Pricelist
for k_price in pricelist.keys(): for k_price in pricelist.keys():
vroom_id = vroom_obj.browse([int(k_price)]) room_type_id = room_type_obj.browse([int(k_price)])
vroom_prod_tmpl_id = vroom_id.product_id.product_tmpl_id room_type_prod_tmpl_id = room_type_id.product_id.product_tmpl_id
for price in pricelist[k_price]: for price in pricelist[k_price]:
price_id = product_pricelist_item_obj.search([ price_id = product_pricelist_item_obj.search([
('date_start', '>=', price['date']), ('date_start', '>=', price['date']),
@@ -65,7 +65,7 @@ class HotelCalendarManagement(models.TransientModel):
('pricelist_id', '=', int(pricelist_id)), ('pricelist_id', '=', int(pricelist_id)),
('applied_on', '=', '1_product'), ('applied_on', '=', '1_product'),
('compute_price', '=', 'fixed'), ('compute_price', '=', 'fixed'),
('product_tmpl_id', '=', vroom_prod_tmpl_id.id), ('product_tmpl_id', '=', room_type_prod_tmpl_id.id),
], limit=1) ], limit=1)
vals = self._get_prices_values(price) vals = self._get_prices_values(price)
if not price_id: if not price_id:
@@ -75,7 +75,7 @@ class HotelCalendarManagement(models.TransientModel):
'pricelist_id': int(pricelist_id), 'pricelist_id': int(pricelist_id),
'applied_on': '1_product', 'applied_on': '1_product',
'compute_price': 'fixed', 'compute_price': 'fixed',
'product_tmpl_id': vroom_prod_tmpl_id.id, 'product_tmpl_id': room_type_prod_tmpl_id.id,
}) })
price_id = product_pricelist_item_obj.create(vals) price_id = product_pricelist_item_obj.create(vals)
else: else:
@@ -84,12 +84,12 @@ class HotelCalendarManagement(models.TransientModel):
# Save Restrictions # Save Restrictions
for k_res in restrictions.keys(): for k_res in restrictions.keys():
for restriction in restrictions[k_res]: for restriction in restrictions[k_res]:
res_id = vroom_rest_item_obj.search([ res_id = room_type_rest_item_obj.search([
('date_start', '>=', restriction['date']), ('date_start', '>=', restriction['date']),
('date_end', '<=', restriction['date']), ('date_end', '<=', restriction['date']),
('restriction_id', '=', int(restriction_id)), ('restriction_id', '=', int(restriction_id)),
('applied_on', '=', '0_virtual_room'), ('applied_on', '=', '0_room_type'),
('virtual_room_id', '=', int(k_res)), ('room_type_id', '=', int(k_res)),
], limit=1) ], limit=1)
vals = self._get_restrictions_values(restriction) vals = self._get_restrictions_values(restriction)
if not res_id: if not res_id:
@@ -97,28 +97,28 @@ class HotelCalendarManagement(models.TransientModel):
'date_start': restriction['date'], 'date_start': restriction['date'],
'date_end': restriction['date'], 'date_end': restriction['date'],
'restriction_id': int(restriction_id), 'restriction_id': int(restriction_id),
'applied_on': '0_virtual_room', 'applied_on': '0_room_type',
'virtual_room_id': int(k_res), 'room_type_id': int(k_res),
}) })
res_id = vroom_rest_item_obj.create(vals) res_id = room_type_rest_item_obj.create(vals)
else: else:
res_id.write(vals) res_id.write(vals)
# Save Availability # Save Availability
for k_avail in availability.keys(): for k_avail in availability.keys():
vroom_id = vroom_obj.browse(int(k_avail)) room_type_id = room_type_obj.browse(int(k_avail))
for avail in availability[k_avail]: for avail in availability[k_avail]:
vals = self._get_availability_values(avail, vroom_id) vals = self._get_availability_values(avail, room_type_id)
avail_id = vroom_avail_obj.search([ avail_id = room_type_avail_obj.search([
('date', '=', avail['date']), ('date', '=', avail['date']),
('virtual_room_id', '=', vroom_id.id), ('room_type_id', '=', room_type_id.id),
], limit=1) ], limit=1)
if not avail_id: if not avail_id:
vals.update({ vals.update({
'date': avail['date'], 'date': avail['date'],
'virtual_room_id': vroom_id.id, 'room_type_id': room_type_id.id,
}) })
avail_id = vroom_avail_obj.with_context({ avail_id = room_type_avail_obj.with_context({
'mail_create_nosubscribe': True, 'mail_create_nosubscribe': True,
}).create(vals) }).create(vals)
else: else:
@@ -140,16 +140,16 @@ class HotelCalendarManagement(models.TransientModel):
@api.model @api.model
def _hcalendar_pricelist_json_data(self, prices): def _hcalendar_pricelist_json_data(self, prices):
json_data = {} json_data = {}
vroom_obj = self.env['hotel.room.type'] room_type_obj = self.env['hotel.room.type']
for rec in prices: for rec in prices:
virtual_room_id = vroom_obj.search([ room_type_id = room_type_obj.search([
('product_id.product_tmpl_id', '=', rec.product_tmpl_id.id) ('product_id.product_tmpl_id', '=', rec.product_tmpl_id.id)
], limit=1) ], limit=1)
if not virtual_room_id: if not room_type_id:
continue continue
# TODO: date_end - date_start loop # TODO: date_end - date_start loop
json_data.setdefault(virtual_room_id.id, []).append({ json_data.setdefault(room_type_id.id, []).append({
'id': rec.id, 'id': rec.id,
'price': rec.fixed_price, 'price': rec.fixed_price,
'date': rec.date_start, 'date': rec.date_start,
@@ -161,7 +161,7 @@ class HotelCalendarManagement(models.TransientModel):
json_data = {} json_data = {}
for rec in restrictions: for rec in restrictions:
# TODO: date_end - date_start loop # TODO: date_end - date_start loop
json_data.setdefault(rec.virtual_room_id.id, []).append({ json_data.setdefault(rec.room_type_id.id, []).append({
'id': rec.id, 'id': rec.id,
'date': rec.date_start, 'date': rec.date_start,
'min_stay': rec.min_stay, 'min_stay': rec.min_stay,
@@ -178,30 +178,30 @@ class HotelCalendarManagement(models.TransientModel):
def _hcalendar_availability_json_data(self, dfrom, dto): def _hcalendar_availability_json_data(self, dfrom, dto):
date_start = date_utils.get_datetime(dfrom, hours=False) date_start = date_utils.get_datetime(dfrom, hours=False)
date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1 date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1
vrooms = self.env['hotel.room.type'].search([]) room_types = self.env['hotel.room.type'].search([])
json_data = {} json_data = {}
for vroom in vrooms: for room_type in room_types:
json_data[vroom.id] = [] json_data[room_type.id] = []
for i in range(0, date_diff): for i in range(0, date_diff):
cur_date = date_start + timedelta(days=i) cur_date = date_start + timedelta(days=i)
cur_date_str = cur_date.strftime(DEFAULT_SERVER_DATE_FORMAT) cur_date_str = cur_date.strftime(DEFAULT_SERVER_DATE_FORMAT)
avail = self.env['hotel.room.type.availability'].search([ avail = self.env['hotel.room.type.availability'].search([
('date', '=', cur_date_str), ('date', '=', cur_date_str),
('virtual_room_id', '=', vroom.id) ('room_type_id', '=', room_type.id)
]) ])
if avail: if avail:
json_data[vroom.id].append({ json_data[room_type.id].append({
'id': avail.id, 'id': avail.id,
'date': avail.date, 'date': avail.date,
'avail': avail.avail, 'avail': avail.avail,
'no_ota': avail.no_ota, 'no_ota': avail.no_ota,
}) })
else: else:
json_data[vroom.id].append({ json_data[room_type.id].append({
'id': False, 'id': False,
'date': cur_date_str, 'date': cur_date_str,
'avail': vroom.max_real_rooms, 'avail': room_type.max_real_rooms,
'no_ota': False, 'no_ota': False,
}) })
return json_data return json_data
@@ -239,25 +239,24 @@ class HotelCalendarManagement(models.TransientModel):
@api.model @api.model
def _hcalendar_get_count_reservations_json_data(self, dfrom, dto): def _hcalendar_get_count_reservations_json_data(self, dfrom, dto):
vrooms = self.env['hotel.room.type'].search([])
date_start = date_utils.get_datetime(dfrom, hours=False) date_start = date_utils.get_datetime(dfrom, hours=False)
date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1 date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1
hotel_vroom_obj = self.env['hotel.room.type'] room_type_obj = self.env['hotel.room.type']
vrooms = hotel_vroom_obj.search([]) room_types = room_type_obj.search([])
json_data = {} json_data = {}
for vroom in vrooms: for room_type in room_types:
for i in range(0, date_diff): for i in range(0, date_diff):
cur_date = date_start + timedelta(days=i) cur_date = date_start + timedelta(days=i)
cur_date_str = cur_date.strftime(DEFAULT_SERVER_DATE_FORMAT) cur_date_str = cur_date.strftime(DEFAULT_SERVER_DATE_FORMAT)
json_data.setdefault(vroom.id, []).append({ json_data.setdefault(room_type.id, []).append({
'date': cur_date_str, 'date': cur_date_str,
'num': len( 'num': len(
hotel_vroom_obj.check_availability_virtual_room( room_type_obj.check_availability_room(
cur_date_str, cur_date_str,
cur_date_str, cur_date_str,
virtual_room_id=vroom.id)), room_type_id=room_type.id)),
}) })
return json_data return json_data
@@ -280,11 +279,11 @@ class HotelCalendarManagement(models.TransientModel):
restriction_id = int(restriction_id) restriction_id = int(restriction_id)
vals.update({'restriction_id': restriction_id}) vals.update({'restriction_id': restriction_id})
vroom_rest_it_obj = self.env['hotel.room.type.restriction.item'] room_type_rest_it_obj = self.env['hotel.room.type.restriction.item']
restriction_item_ids = vroom_rest_it_obj.search([ restriction_item_ids = room_type_rest_it_obj.search([
('date_start', '>=', dfrom), ('date_end', '<=', dto), ('date_start', '>=', dfrom), ('date_end', '<=', dto),
('restriction_id', '=', restriction_id), ('restriction_id', '=', restriction_id),
('applied_on', '=', '0_virtual_room'), ('applied_on', '=', '0_room_type'),
]) ])
pricelist_item_ids = self.env['product.pricelist.item'].search([ pricelist_item_ids = self.env['product.pricelist.item'].search([

View File

@@ -64,7 +64,6 @@ class HotelReservation(models.Model):
if pricelist_id: if pricelist_id:
pricelist_id = int(pricelist_id) pricelist_id = int(pricelist_id)
json_rooms = [] json_rooms = []
room_type_obj = self.env['hotel.room.type']
for room in rooms: for room in rooms:
json_rooms.append(( json_rooms.append((
room.id, room.id,
@@ -168,20 +167,20 @@ class HotelReservation(models.Model):
date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1 date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1
# Get Prices # Get Prices
json_rooms_rests = {} json_rooms_rests = {}
room_type_ids = self.env['hotel.room.type'].search( room_types = self.env['hotel.room.type'].search(
[], [],
order='hcal_sequence ASC') order='hcal_sequence ASC')
vroom_rest_obj = self.env['hotel.room.type.restriction.item'] room_type_rest_obj = self.env['hotel.room.type.restriction.item']
for room_type_id in room_type_ids: for room_type in room_types:
days = {} days = {}
for i in range(0, date_diff): for i in range(0, date_diff):
ndate = date_start + timedelta(days=i) ndate = date_start + timedelta(days=i)
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT) ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
rest_id = vroom_rest_obj.search([ rest_id = room_type_rest_obj.search([
('room_type_id', '=', room_type_id.id), ('room_type_id', '=', room_type.id),
('date_start', '>=', ndate_str), ('date_start', '>=', ndate_str),
('date_end', '<=', ndate_str), ('date_end', '<=', ndate_str),
('applied_on', '=', '0_virtual_room'), ('applied_on', '=', '0_room_type'),
('restriction_id', '=', restriction_id) ('restriction_id', '=', restriction_id)
], limit=1) ], limit=1)
if rest_id and (rest_id.min_stay or rest_id.min_stay_arrival or if rest_id and (rest_id.min_stay or rest_id.min_stay_arrival or
@@ -198,7 +197,7 @@ class HotelReservation(models.Model):
rest_id.closed_arrival, rest_id.closed_arrival,
rest_id.closed_departure) rest_id.closed_departure)
}) })
json_rooms_rests.update({room_type_id.id: days}) json_rooms_rests.update({room_type.id: days})
return json_rooms_rests return json_rooms_rests
@api.model @api.model

View File

@@ -3,7 +3,7 @@
from odoo import models, fields, api from odoo import models, fields, api
class HotelVirtualRoomAvailability(models.Model): class HotelRoomTypeAvailability(models.Model):
_inherit = 'hotel.room.type.availability' _inherit = 'hotel.room.type.availability'
@api.model @api.model
@@ -13,7 +13,7 @@ class HotelVirtualRoomAvailability(models.Model):
'date': res.date, 'date': res.date,
'avail': res.avail, 'avail': res.avail,
'no_ota': res.no_ota, 'no_ota': res.no_ota,
'virtual_room_id': res.virtual_room_id.id, 'room_type_id': res.room_type_id.id,
'id': res.id, 'id': res.id,
}) })
return res return res
@@ -27,7 +27,7 @@ class HotelVirtualRoomAvailability(models.Model):
'date': record.date, 'date': record.date,
'avail': record.avail, 'avail': record.avail,
'no_ota': record.no_ota, 'no_ota': record.no_ota,
'virtual_room_id': record.virtual_room_id.id, 'room_type_id': record.room_type_id.id,
'id': record.id, 'id': record.id,
}) })
return ret_vals return ret_vals
@@ -39,8 +39,8 @@ class HotelVirtualRoomAvailability(models.Model):
for record in self: for record in self:
unlink_vals.append({ unlink_vals.append({
'date': record.date, 'date': record.date,
'avail': record.virtual_room_id.max_real_rooms, 'avail': record.room_type_id.max_real_rooms,
'virtual_room_id': record.virtual_room_id.id, 'room_type_id': record.room_type_id.id,
'no_ota': False, 'no_ota': False,
'id': record.id, 'id': record.id,
}) })

View File

@@ -5,7 +5,7 @@ from odoo import models, fields, api
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class HotelVirtualRoomResrtrictionItem(models.Model): class HotelRoomTypeResrtrictionItem(models.Model):
_inherit = 'hotel.room.type.restriction.item' _inherit = 'hotel.room.type.restriction.item'
@api.model @api.model
@@ -17,7 +17,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
restrictions_parity_id = int(restrictions_parity_id) restrictions_parity_id = int(restrictions_parity_id)
restriction_id = res.restriction_id.id restriction_id = res.restriction_id.id
if restriction_id == restrictions_parity_id and \ if restriction_id == restrictions_parity_id and \
self.applied_on == '0_virtual_room': self.applied_on == '0_room_type':
self.env['bus.hotel.calendar'].send_restriction_notification({ self.env['bus.hotel.calendar'].send_restriction_notification({
'restriction_id': self.restriction_id.id, 'restriction_id': self.restriction_id.id,
'date': self.date_start, 'date': self.date_start,
@@ -28,7 +28,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
'closed': self.closed, 'closed': self.closed,
'closed_departure': self.closed_departure, 'closed_departure': self.closed_departure,
'closed_arrival': self.closed_arrival, 'closed_arrival': self.closed_arrival,
'virtual_room_id': self.virtual_room_id.id, 'room_type_id': self.room_type_id.id,
'id': self.id, 'id': self.id,
}) })
return res return res
@@ -44,7 +44,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
bus_hotel_calendar_obj = self.env['bus.hotel.calendar'] bus_hotel_calendar_obj = self.env['bus.hotel.calendar']
for record in self: for record in self:
if record.restriction_id.id != restrictions_parity_id or \ if record.restriction_id.id != restrictions_parity_id or \
record.applied_on != '0_virtual_room': record.applied_on != '0_room_type':
continue continue
bus_hotel_calendar_obj.send_restriction_notification({ bus_hotel_calendar_obj.send_restriction_notification({
'restriction_id': record.restriction_id.id, 'restriction_id': record.restriction_id.id,
@@ -56,7 +56,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
'closed': record.closed, 'closed': record.closed,
'closed_departure': record.closed_departure, 'closed_departure': record.closed_departure,
'closed_arrival': record.closed_arrival, 'closed_arrival': record.closed_arrival,
'virtual_room_id': record.virtual_room_id.id, 'room_type_id': record.room_type_id.id,
'id': record.id, 'id': record.id,
}) })
return ret_vals return ret_vals
@@ -71,7 +71,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
unlink_vals = [] unlink_vals = []
for record in self: for record in self:
if record.restriction_id.id != restrictions_parity_id or \ if record.restriction_id.id != restrictions_parity_id or \
record.applied_on != '0_virtual_room': record.applied_on != '0_room_type':
continue continue
unlink_vals.append({ unlink_vals.append({
'restriction_id': record.restriction_id.id, 'restriction_id': record.restriction_id.id,
@@ -83,7 +83,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
'closed': False, 'closed': False,
'closed_departure': False, 'closed_departure': False,
'closed_arrival': False, 'closed_arrival': False,
'virtual_room_id': record.virtual_room_id.id, 'room_type_id': record.room_type_id.id,
'id': record.id, 'id': record.id,
}) })
res = super(HotelVirtualRoomResrtrictionItem, self).unlink() res = super(HotelVirtualRoomResrtrictionItem, self).unlink()

View File

@@ -18,19 +18,19 @@ class IrDefault(models.Model):
pricelist_items = self.env['product.pricelist.item'].search([ pricelist_items = self.env['product.pricelist.item'].search([
('pricelist_id', '=', pricelist_id) ('pricelist_id', '=', pricelist_id)
]) ])
vroom_obj = self.env['hotel.room.type'] room_type_obj = self.env['hotel.room.type']
vroom_pr_cached_obj = self.env['room.pricelist.cached'] room_pr_cached_obj = self.env['room.pricelist.cached']
for pitem in pricelist_items: for pitem in pricelist_items:
date_start = pitem.date_start date_start = pitem.date_start
product_tmpl_id = pitem.product_tmpl_id.id product_tmpl_id = pitem.product_tmpl_id.id
fixed_price = pitem.fixed_price fixed_price = pitem.fixed_price
vroom = vroom_obj.search([ room_type = room_type_obj.search([
('product_id.product_tmpl_id', '=', product_tmpl_id), ('product_id.product_tmpl_id', '=', product_tmpl_id),
('date_start', '>=', date_utils.now().strftime( ('date_start', '>=', date_utils.now().strftime(
DEFAULT_SERVER_DATETIME_FORMAT)) DEFAULT_SERVER_DATETIME_FORMAT))
], limit=1) ], limit=1)
vroom_pr_cached_obj.create({ room_pr_cached_obj.create({
'virtual_room_id': vroom.id, 'room_type_id': room_type.id,
'date': date_start, 'date': date_start,
'price': fixed_price, 'price': fixed_price,
}) })

View File

@@ -19,7 +19,7 @@ class ProductPricelistItem(models.Model):
room_type = self.env['hotel.room.type'].search([ room_type = self.env['hotel.room.type'].search([
('product_id.product_tmpl_id', '=', product_tmpl_id) ('product_id.product_tmpl_id', '=', product_tmpl_id)
], limit=1) ], limit=1)
if pricelist_id == pricelist_parity_id and vroom: if pricelist_id == pricelist_parity_id and room_type:
prod = room_type.product_id.with_context( prod = room_type.product_id.with_context(
quantity=1, quantity=1,
date=date_start, date=date_start,
@@ -88,12 +88,12 @@ class ProductPricelistItem(models.Model):
'id': record.id, 'id': record.id,
}) })
vroom_pr_cached_id = room_pr_cached_obj.search([ room_pr_cached_id = room_pr_cached_obj.search([
('room_id', '=', room_type.id), ('room_id', '=', room_type.id),
('date', '=', date_start), ('date', '=', date_start),
], limit=1) ], limit=1)
if vroom_pr_cached_id: if room_pr_cached_id:
vroom_pr_cached_id.write({'price': prod_price}) room_pr_cached_id.write({'price': prod_price})
else: else:
room_pr_cached_obj.create({ room_pr_cached_obj.create({
'room_id': room_type.id, 'room_id': room_type.id,

View File

@@ -60,7 +60,7 @@ return AbstractModel.extend({
return this._rpc({ return this._rpc({
model: 'hotel.room.type', model: 'hotel.room.type',
method: 'search_read', method: 'search_read',
args: [false, ['cat_id','name']], args: [false, ['id','name']],
context: Session.user_context, context: Session.user_context,
}); });
}, },

View File

@@ -71,7 +71,7 @@ var MPMSCalendarController = AbstractController.extend({
self.renderer._days_tooltips = results['events']; self.renderer._days_tooltips = results['events'];
var rooms = []; var rooms = [];
for (var r of results['rooms']) { for (var r of results['rooms']) {
var nroom = new HVRoom( var nroom = new HRoomType(
r[0], // Id r[0], // Id
r[1], // Name r[1], // Name
r[2], // Capacity r[2], // Capacity
@@ -112,15 +112,15 @@ var MPMSCalendarController = AbstractController.extend({
switch (notif[1]['type']) { switch (notif[1]['type']) {
case 'availability': case 'availability':
var avail = notif[1]['availability']; var avail = notif[1]['availability'];
var vroom = Object.keys(avail)[0]; var room_type = Object.keys(avail)[0];
var day = Object.keys(avail[vroom])[0]; var day = Object.keys(avail[room_type])[0];
var dt = HotelCalendarManagement.toMoment(day); var dt = HotelCalendarManagement.toMoment(day);
var availability = {}; var availability = {};
availability[vroom] = [{ availability[room_type] = [{
'date': dt.format(ODOO_DATE_MOMENT_FORMAT), 'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
'avail': avail[vroom][day][0], 'avail': avail[room_type][day][0],
'no_ota': avail[vroom][day][1], 'no_ota': avail[room_type][day][1],
'id': avail[vroom][day][2] 'id': avail[room_type][day][2]
}]; }];
this.renderer._hcalendar.addAvailability(availability); this.renderer._hcalendar.addAvailability(availability);
break; break;
@@ -143,22 +143,22 @@ var MPMSCalendarController = AbstractController.extend({
this.renderer._hcalendar.addPricelist(pr); this.renderer._hcalendar.addPricelist(pr);
break; break;
case 'restriction': case 'restriction':
// FIXME: Expected one day and one vroom // FIXME: Expected one day and one room_type
var restriction = notif[1]['restriction']; var restriction = notif[1]['restriction'];
var vroom = Object.keys(restriction)[0]; var room_type = Object.keys(restriction)[0];
var day = Object.keys(restriction[vroom])[0]; var day = Object.keys(restriction[room_type])[0];
var dt = HotelCalendarManagement.toMoment(day); var dt = HotelCalendarManagement.toMoment(day);
var rest = {}; var rest = {};
rest[vroom] = [{ rest[room_type] = [{
'date': dt.format(ODOO_DATE_MOMENT_FORMAT), 'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
'min_stay': restriction[vroom][day][0], 'min_stay': restriction[room_type][day][0],
'min_stay_arrival': restriction[vroom][day][1], 'min_stay_arrival': restriction[room_type][day][1],
'max_stay': restriction[vroom][day][2], 'max_stay': restriction[room_type][day][2],
'max_stay_arrival': restriction[vroom][day][3], 'max_stay_arrival': restriction[room_type][day][3],
'closed': restriction[vroom][day][4], 'closed': restriction[room_type][day][4],
'closed_arrival': restriction[vroom][day][5], 'closed_arrival': restriction[room_type][day][5],
'closed_departure': restriction[vroom][day][6], 'closed_departure': restriction[room_type][day][6],
'id': restriction[vroom][day][7] 'id': restriction[room_type][day][7]
}]; }];
this.renderer._hcalendar.addRestrictions(rest); this.renderer._hcalendar.addRestrictions(rest);
break; break;

View File

@@ -132,7 +132,7 @@ var HotelCalendarManagementView = AbstractRenderer.extend({
this._hcalendar = new HotelCalendarManagement('#hcal_management_widget', options, this.$el[0]); this._hcalendar = new HotelCalendarManagement('#hcal_management_widget', options, this.$el[0]);
this._assignHCalendarEvents(); this._assignHCalendarEvents();
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header"); this.$CalendarHeaderDays = this.$el.find("div.table-room_type-data-header");
// Sticky Header Days // Sticky Header Days
this.$ehcal.scroll(this._on_scroll.bind(this)); this.$ehcal.scroll(this._on_scroll.bind(this));
@@ -409,7 +409,7 @@ var HotelCalendarManagementView = AbstractRenderer.extend({
self._assign_extra_info(); self._assign_extra_info();
}); });
this._last_dates = params['dates']; this._last_dates = params['dates'];
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header"); this.$CalendarHeaderDays = this.$el.find("div.table-room_type-data-header");
this._on_scroll(); // FIXME: Workaround for update sticky header this._on_scroll(); // FIXME: Workaround for update sticky header
}, },

View File

@@ -173,7 +173,7 @@ var HotelCalendarManagementView = View.extend({
} }
}); });
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header"); this.$CalendarHeaderDays = this.$el.find("div.table-room_type-data-header");
// Sticky Header Days // Sticky Header Days
this.$ehcal.scroll(this._on_scroll.bind(this)); this.$ehcal.scroll(this._on_scroll.bind(this));
@@ -204,7 +204,7 @@ var HotelCalendarManagementView = View.extend({
self._days_tooltips = results['events']; self._days_tooltips = results['events'];
var rooms = []; var rooms = [];
for (var r of results['rooms']) { for (var r of results['rooms']) {
var nroom = new HVRoom( var nroom = new HRoomType(
r[0], // Id r[0], // Id
r[1], // Name r[1], // Name
r[2], // Capacity r[2], // Capacity
@@ -478,15 +478,15 @@ var HotelCalendarManagementView = View.extend({
switch (notif[1]['type']) { switch (notif[1]['type']) {
case 'availability': case 'availability':
var avail = notif[1]['availability']; var avail = notif[1]['availability'];
var vroom = Object.keys(avail)[0]; var room_type = Object.keys(avail)[0];
var day = Object.keys(avail[vroom])[0]; var day = Object.keys(avail[room_type])[0];
var dt = HotelCalendarManagement.toMoment(day); var dt = HotelCalendarManagement.toMoment(day);
var availability = {}; var availability = {};
availability[vroom] = [{ availability[room_type] = [{
'date': dt.format(ODOO_DATE_MOMENT_FORMAT), 'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
'avail': avail[vroom][day][0], 'avail': avail[room_type][day][0],
'no_ota': avail[vroom][day][1], 'no_ota': avail[room_type][day][1],
'id': avail[vroom][day][2] 'id': avail[room_type][day][2]
}]; }];
this._hcalendar.addAvailability(availability); this._hcalendar.addAvailability(availability);
break; break;
@@ -509,22 +509,22 @@ var HotelCalendarManagementView = View.extend({
this._hcalendar.addPricelist(pr); this._hcalendar.addPricelist(pr);
break; break;
case 'restriction': case 'restriction':
// FIXME: Expected one day and one vroom // FIXME: Expected one day and one room_type
var restriction = notif[1]['restriction']; var restriction = notif[1]['restriction'];
var vroom = Object.keys(restriction)[0]; var room_type = Object.keys(restriction)[0];
var day = Object.keys(restriction[vroom])[0]; var day = Object.keys(restriction[room_type])[0];
var dt = HotelCalendarManagement.toMoment(day); var dt = HotelCalendarManagement.toMoment(day);
var rest = {}; var rest = {};
rest[vroom] = [{ rest[room_type] = [{
'date': dt.format(ODOO_DATE_MOMENT_FORMAT), 'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
'min_stay': restriction[vroom][day][0], 'min_stay': restriction[room_type][day][0],
'min_stay_arrival': restriction[vroom][day][1], 'min_stay_arrival': restriction[room_type][day][1],
'max_stay': restriction[vroom][day][2], 'max_stay': restriction[room_type][day][2],
'max_stay_arrival': restriction[vroom][day][3], 'max_stay_arrival': restriction[room_type][day][3],
'closed': restriction[vroom][day][4], 'closed': restriction[room_type][day][4],
'closed_arrival': restriction[vroom][day][5], 'closed_arrival': restriction[room_type][day][5],
'closed_departure': restriction[vroom][day][6], 'closed_departure': restriction[room_type][day][6],
'id': restriction[vroom][day][7] 'id': restriction[room_type][day][7]
}]; }];
this._hcalendar.addRestrictions(rest); this._hcalendar.addRestrictions(rest);
break; break;
@@ -543,7 +543,7 @@ var HotelCalendarManagementView = View.extend({
self._assign_extra_info(); self._assign_extra_info();
}); });
this._last_dates = params['dates']; this._last_dates = params['dates'];
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header"); this.$CalendarHeaderDays = this.$el.find("div.table-room_type-data-header");
this._on_scroll(); // FIXME: Workaround for update sticky header this._on_scroll(); // FIXME: Workaround for update sticky header
}, },

View File

@@ -690,8 +690,8 @@ HotelCalendar.prototype = {
}, },
addRestrictions: function(/*Object*/restrictions) { addRestrictions: function(/*Object*/restrictions) {
var vroom_ids = Object.keys(restrictions); var room_type_ids = Object.keys(restrictions);
for (var vid of vroom_ids) { for (var vid of room_type_ids) {
if (vid in this._restrictions) { if (vid in this._restrictions) {
this._restrictions[vid] = _.extend(this._restrictions[vid], restrictions[vid]); this._restrictions[vid] = _.extend(this._restrictions[vid], restrictions[vid]);
} }
@@ -1276,7 +1276,7 @@ HotelCalendar.prototype = {
row = tbody.insertRow(); row = tbody.insertRow();
row.setAttribute('id', this._sanitizeId(`ROW_DETAIL_PRICE_ROOM_${key}_${listitem.room}`)); row.setAttribute('id', this._sanitizeId(`ROW_DETAIL_PRICE_ROOM_${key}_${listitem.room}`));
row.dataset.hcalPricelist = key; row.dataset.hcalPricelist = key;
row.dataset.hcalVRoomId = listitem.room row.dataset.hcalRoomTypeId = listitem.room
row.classList.add('hcal-row-detail-room-price-group-item'); row.classList.add('hcal-row-detail-room-price-group-item');
cell = row.insertCell(); cell = row.insertCell();
var span = document.createElement('span'); var span = document.createElement('span');
@@ -1306,7 +1306,7 @@ HotelCalendar.prototype = {
input.setAttribute('id', this._sanitizeId(`INPUT_PRICE_${key}_${listitem.room}_${dd_local.format(HotelCalendar.DATE_FORMAT_SHORT_)}`)); input.setAttribute('id', this._sanitizeId(`INPUT_PRICE_${key}_${listitem.room}_${dd_local.format(HotelCalendar.DATE_FORMAT_SHORT_)}`));
input.setAttribute('type', 'edit'); input.setAttribute('type', 'edit');
input.setAttribute('title', 'Price'); input.setAttribute('title', 'Price');
input.setAttribute('name', 'vroom_price_day'); input.setAttribute('name', 'room_type_price_day');
input.dataset.hcalParentCell = cell.getAttribute('id'); input.dataset.hcalParentCell = cell.getAttribute('id');
var dd_fmrt = dd_local.format(HotelCalendar.DATE_FORMAT_SHORT_); var dd_fmrt = dd_local.format(HotelCalendar.DATE_FORMAT_SHORT_);
input.dataset.orgValue = input.value = _.has(listitem['days'], dd_fmrt)?Number(listitem['days'][dd_fmrt]).toLocaleString():'...'; input.dataset.orgValue = input.value = _.has(listitem['days'], dd_fmrt)?Number(listitem['days'][dd_fmrt]).toLocaleString():'...';
@@ -1335,8 +1335,8 @@ HotelCalendar.prototype = {
var orgValue = input.dataset.orgValue; var orgValue = input.dataset.orgValue;
var parentCell = this.edtable.querySelector(`#${input.dataset.hcalParentCell}`); var parentCell = this.edtable.querySelector(`#${input.dataset.hcalParentCell}`);
var parentRow = this.edtable.querySelector(`#${parentCell.dataset.hcalParentRow}`); var parentRow = this.edtable.querySelector(`#${parentCell.dataset.hcalParentRow}`);
if (!(parentRow.dataset.hcalVRoomId in data)) { data[parentRow.dataset.hcalVRoomId] = []; } if (!(parentRow.dataset.hcalRoomTypeId in data)) { data[parentRow.dataset.hcalRoomTypeId] = []; }
data[parentRow.dataset.hcalVRoomId].push({ data[parentRow.dataset.hcalRoomTypeId].push({
'date': HotelCalendar.toMoment(parentCell.dataset.hcalDate).format('YYYY-MM-DD'), 'date': HotelCalendar.toMoment(parentCell.dataset.hcalDate).format('YYYY-MM-DD'),
'price': value 'price': value
}); });
@@ -2107,13 +2107,13 @@ HotelCalendar.prototype = {
this._updatePriceList(); this._updatePriceList();
}, },
updateVRoomPrice: function(pricelist_id, vroom_id, date, price) { updateRoomTypePrice: function(pricelist_id, room_type_id, date, price) {
var strDate = date.format(HotelCalendar.DATE_FORMAT_SHORT_); var strDate = date.format(HotelCalendar.DATE_FORMAT_SHORT_);
var cellId = this._sanitizeId(`CELL_PRICE_${pricelist_id}_${vroom_id}_${strDate}`); var cellId = this._sanitizeId(`CELL_PRICE_${pricelist_id}_${room_type_id}_${strDate}`);
var input = this.edtable.querySelector(`#${cellId} input`); var input = this.edtable.querySelector(`#${cellId} input`);
if (input) { if (input) {
input.dataset.orgValue = input.value = price; input.dataset.orgValue = input.value = price;
var pr_fk = _.findKey(this._pricelist[pricelist_id], {'room': vroom_id}); var pr_fk = _.findKey(this._pricelist[pricelist_id], {'room': room_type_id});
this._pricelist[pricelist_id][pr_fk].days[strDate] = price; this._pricelist[pricelist_id][pr_fk].days[strDate] = price;
} }
}, },
@@ -2289,7 +2289,7 @@ HotelCalendar.prototype = {
var orgValue = elm.dataset.orgValue; var orgValue = elm.dataset.orgValue;
var name = elm.getAttribute('name'); var name = elm.getAttribute('name');
if (name === 'vroom_price_day') { if (name === 'room_type_price_day') {
if (!this._isNumeric(value)) { if (!this._isNumeric(value)) {
elm.style.backgroundColor = 'red'; elm.style.backgroundColor = 'red';
} else if (orgValue !== value) { } else if (orgValue !== value) {
@@ -2306,13 +2306,13 @@ HotelCalendar.prototype = {
var parentCell = this.edtable.querySelector(`#${elm.dataset.hcalParentCell}`); var parentCell = this.edtable.querySelector(`#${elm.dataset.hcalParentCell}`);
var parentRow = this.edtable.querySelector(`#${parentCell.dataset.hcalParentRow}`); var parentRow = this.edtable.querySelector(`#${parentCell.dataset.hcalParentRow}`);
var vals = { var vals = {
'vroom_id': +parentRow.dataset.hcalVRoomId, 'room_type_id': +parentRow.dataset.hcalRoomTypeId,
'date': HotelCalendar.toMoment(parentCell.dataset.hcalDate), 'date': HotelCalendar.toMoment(parentCell.dataset.hcalDate),
'price': value, 'price': value,
'old_price': orgValue, 'old_price': orgValue,
'pricelist_id': +parentRow.dataset.hcalPricelist 'pricelist_id': +parentRow.dataset.hcalPricelist
}; };
//this.updateVRoomPrice(vals['pricelist_id'], vals['vroom_id'], vals['date'], vals['price']); //this.updateRoomTypePrice(vals['pricelist_id'], vals['room_type_id'], vals['date'], vals['price']);
this._dispatchEvent('hcalOnPricelistChanged', vals); this._dispatchEvent('hcalOnPricelistChanged', vals);
if (this.edivc.querySelector('.hcal-input-changed') !== null) if (this.edivc.querySelector('.hcal-input-changed') !== null)

View File

@@ -74,7 +74,7 @@ function HotelCalendarManagement(/*String*/querySelector, /*Dictionary*/options,
}; };
// Check correct values // Check correct values
if (this.options.rooms.length > 0 && !(this.options.rooms[0] instanceof HVRoom)) { if (this.options.rooms.length > 0 && !(this.options.rooms[0] instanceof HRoomType)) {
this.options.rooms = []; this.options.rooms = [];
console.warn("[Hotel Calendar Management][init] Invalid Room definiton!"); console.warn("[Hotel Calendar Management][init] Invalid Room definiton!");
} }
@@ -397,9 +397,9 @@ HotelCalendarManagement.prototype = {
this.e.removeChild(this.e.lastChild); this.e.removeChild(this.e.lastChild);
} }
// VRoom Names // RoomType Names
this.edivrhl = document.createElement("div"); this.edivrhl = document.createElement("div");
this.edivrhl.classList.add('table-vrooms'); this.edivrhl.classList.add('table-room_types');
this.e.appendChild(this.edivrhl); this.e.appendChild(this.edivrhl);
this.etableRooms = document.createElement("table"); this.etableRooms = document.createElement("table");
this.etableRooms.classList.add('hcal-management-table'); this.etableRooms.classList.add('hcal-management-table');
@@ -412,7 +412,7 @@ HotelCalendarManagement.prototype = {
this.e.appendChild(this.edivm); this.e.appendChild(this.edivm);
// Days // Days
this.edivrh = document.createElement("div"); this.edivrh = document.createElement("div");
this.edivrh.classList.add('table-vroom-data-header'); this.edivrh.classList.add('table-room_type-data-header');
this.edivm.appendChild(this.edivrh); this.edivm.appendChild(this.edivrh);
this.etableHeader = document.createElement("table"); this.etableHeader = document.createElement("table");
this.etableHeader.classList.add('hcal-management-table'); this.etableHeader.classList.add('hcal-management-table');
@@ -420,7 +420,7 @@ HotelCalendarManagement.prototype = {
this.edivrh.appendChild(this.etableHeader); this.edivrh.appendChild(this.etableHeader);
// Data // Data
this.edivr = document.createElement("div"); this.edivr = document.createElement("div");
this.edivr.classList.add('table-vroom-data'); this.edivr.classList.add('table-room_type-data');
this.edivm.appendChild(this.edivr); this.edivm.appendChild(this.edivr);
this.etable = document.createElement("table"); this.etable = document.createElement("table");
this.etable.classList.add('hcal-management-table'); this.etable.classList.add('hcal-management-table');
@@ -503,8 +503,8 @@ HotelCalendarManagement.prototype = {
//==== PRICELIST //==== PRICELIST
addPricelist: function(/*Object*/pricelist) { addPricelist: function(/*Object*/pricelist) {
var vroom_ids = Object.keys(pricelist); var room_type_ids = Object.keys(pricelist);
for (var vid of vroom_ids) { for (var vid of room_type_ids) {
if (vid in this._pricelist) { if (vid in this._pricelist) {
for (var price of pricelist[vid]) { for (var price of pricelist[vid]) {
var index = _.findIndex(this._pricelist[vid], {date: price['date']}); var index = _.findIndex(this._pricelist[vid], {date: price['date']});
@@ -524,10 +524,10 @@ HotelCalendarManagement.prototype = {
_updatePriceList: function() { _updatePriceList: function() {
var keys = Object.keys(this._pricelist); var keys = Object.keys(this._pricelist);
for (var vroomId of keys) { for (var room_typeId of keys) {
for (var price of this._pricelist[vroomId]) { for (var price of this._pricelist[room_typeId]) {
var dd = HotelCalendarManagement.toMoment(price.date, this.options.dateFormatShort); var dd = HotelCalendarManagement.toMoment(price.date, this.options.dateFormatShort);
var inputId = this._sanitizeId(`PRICE_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`); var inputId = this._sanitizeId(`PRICE_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`);
var input = this.etable.querySelector(`#${inputId}`); var input = this.etable.querySelector(`#${inputId}`);
if (input && !input.classList.contains('hcal-management-input-changed')) { if (input && !input.classList.contains('hcal-management-input-changed')) {
input.dataset.orgValue = price.price; input.dataset.orgValue = price.price;
@@ -559,8 +559,8 @@ HotelCalendarManagement.prototype = {
//==== RESTRICTIONS //==== RESTRICTIONS
addRestrictions: function(/*Object*/restrictions) { addRestrictions: function(/*Object*/restrictions) {
var vroom_ids = Object.keys(restrictions); var room_type_ids = Object.keys(restrictions);
for (var vid of vroom_ids) { for (var vid of room_type_ids) {
if (vid in this._restrictions) { if (vid in this._restrictions) {
for (var rest of restrictions[vid]) { for (var rest of restrictions[vid]) {
var index = _.findIndex(this._restrictions[vid], {date: rest['date']}); var index = _.findIndex(this._restrictions[vid], {date: rest['date']});
@@ -580,15 +580,15 @@ HotelCalendarManagement.prototype = {
_updateRestrictions: function() { _updateRestrictions: function() {
var keys = Object.keys(this._restrictions); var keys = Object.keys(this._restrictions);
for (var vroomId of keys) { for (var room_typeId of keys) {
var room = this.getRoom(vroomId); var room = this.getRoom(room_typeId);
for (var restriction of this._restrictions[vroomId]) { for (var restriction of this._restrictions[room_typeId]) {
var dd = HotelCalendarManagement.toMoment(restriction.date, this.options.dateFormatShort); var dd = HotelCalendarManagement.toMoment(restriction.date, this.options.dateFormatShort);
var inputIds = [ var inputIds = [
this._sanitizeId(`MIN_STAY_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.min_stay, this._sanitizeId(`MIN_STAY_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.min_stay,
this._sanitizeId(`MIN_STAY_ARRIVAL_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.min_stay_arrival, this._sanitizeId(`MIN_STAY_ARRIVAL_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.min_stay_arrival,
this._sanitizeId(`MAX_STAY_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.max_stay, this._sanitizeId(`MAX_STAY_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.max_stay,
this._sanitizeId(`MAX_STAY_ARRIVAL_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.max_stay_arrival, this._sanitizeId(`MAX_STAY_ARRIVAL_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.max_stay_arrival,
]; ];
for (var i=0; i<inputIds.length; i+=2) { for (var i=0; i<inputIds.length; i+=2) {
var inputItem = this.etable.querySelector(`#${inputIds[i]}`); var inputItem = this.etable.querySelector(`#${inputIds[i]}`);
@@ -598,7 +598,7 @@ HotelCalendarManagement.prototype = {
} }
} }
var inputClousureId = this._sanitizeId(`CLOUSURE_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`); var inputClousureId = this._sanitizeId(`CLOUSURE_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`);
var inputClousure = this.etable.querySelector(`#${inputClousureId}`); var inputClousure = this.etable.querySelector(`#${inputClousureId}`);
if (inputClousure && !inputClousure.classList.contains('hcal-management-input-changed')) { if (inputClousure && !inputClousure.classList.contains('hcal-management-input-changed')) {
inputClousure.dataset.orgValue = inputClousure.value = (restriction.closed && 'closed') || inputClousure.dataset.orgValue = inputClousure.value = (restriction.closed && 'closed') ||
@@ -651,11 +651,11 @@ HotelCalendarManagement.prototype = {
//==== FREE Rooms //==== FREE Rooms
_updateNumFreeRooms: function() { _updateNumFreeRooms: function() {
var keys = Object.keys(this._free_rooms); var keys = Object.keys(this._free_rooms);
for (var vroomId of keys) { for (var room_typeId of keys) {
for (var fnroom of this._free_rooms[vroomId]) { for (var fnroom of this._free_rooms[room_typeId]) {
var dd = HotelCalendarManagement.toMoment(fnroom.date, this.options.dateFormatShort); var dd = HotelCalendarManagement.toMoment(fnroom.date, this.options.dateFormatShort);
var inputIds = [ var inputIds = [
`FREE_ROOMS_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, fnroom.num, `FREE_ROOMS_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, fnroom.num,
]; ];
for (var i=0; i<inputIds.length; i+=2) { for (var i=0; i<inputIds.length; i+=2) {
@@ -671,8 +671,8 @@ HotelCalendarManagement.prototype = {
//==== AVAILABILITY //==== AVAILABILITY
addAvailability: function(/*Object*/availability) { addAvailability: function(/*Object*/availability) {
var vroom_ids = Object.keys(availability); var room_type_ids = Object.keys(availability);
for (var vid of vroom_ids) { for (var vid of room_type_ids) {
if (vid in this._availability) { if (vid in this._availability) {
for (var avail of availability[vid]) { for (var avail of availability[vid]) {
var index = _.findIndex(this._availability[vid], {date: avail['date']}); var index = _.findIndex(this._availability[vid], {date: avail['date']});
@@ -692,12 +692,12 @@ HotelCalendarManagement.prototype = {
_updateAvailability: function() { _updateAvailability: function() {
var keys = Object.keys(this._availability); var keys = Object.keys(this._availability);
for (var vroomId of keys) { for (var room_typeId of keys) {
for (var avail of this._availability[vroomId]) { for (var avail of this._availability[room_typeId]) {
var dd = HotelCalendarManagement.toMoment(avail.date, this.options.dateFormatShort); var dd = HotelCalendarManagement.toMoment(avail.date, this.options.dateFormatShort);
var inputIds = [ var inputIds = [
`AVAIL_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.avail, `AVAIL_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.avail,
`NO_OTA_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.no_ota `NO_OTA_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.no_ota
]; ];
for (var i=0; i<inputIds.length; i+=2) { for (var i=0; i<inputIds.length; i+=2) {
@@ -1062,7 +1062,7 @@ HotelCalendarManagement.toMoment = function(/*String,MomentObject*/ndate, /*Stri
/** ROOM OBJECT **/ /** ROOM OBJECT **/
function HVRoom(/*Int*/id, /*String*/name, /*Int*/capacity, /*Float*/price) { function HRoomType(/*Int*/id, /*String*/name, /*Int*/capacity, /*Float*/price) {
this.id = id || -1; this.id = id || -1;
this.name = name; this.name = name;
this.capacity = capacity; this.capacity = capacity;
@@ -1070,7 +1070,7 @@ function HVRoom(/*Int*/id, /*String*/name, /*Int*/capacity, /*Float*/price) {
this.userData_ = {}; this.userData_ = {};
} }
HVRoom.prototype = { HRoomType.prototype = {
clearUserData: function() { this.userData_ = {}; }, clearUserData: function() { this.userData_ = {}; },
getUserData: function(/*String?*/key) { getUserData: function(/*String?*/key) {
if (typeof key === 'undefined') { if (typeof key === 'undefined') {
@@ -1080,7 +1080,7 @@ HVRoom.prototype = {
}, },
addUserData: function(/*Dictionary*/data) { addUserData: function(/*Dictionary*/data) {
if (!_.isObject(data)) { if (!_.isObject(data)) {
console.warn("[Hotel Calendar Management][HVRoom][setUserData] Invalid Data! Need be a object!"); console.warn("[Hotel Calendar Management][HRoomType][setUserData] Invalid Data! Need be a object!");
} else { } else {
this.userData_ = _.extend(this.userData_, data); this.userData_ = _.extend(this.userData_, data);
} }

View File

@@ -112,9 +112,9 @@ class TestManagementCalendar(TestHotelCalendar):
rest_it_obj = self.env['hotel.room.type.restriction.item'].sudo( rest_it_obj = self.env['hotel.room.type.restriction.item'].sudo(
self.user_hotel_manager) self.user_hotel_manager)
rest_ids = rest_it_obj.search([ rest_ids = rest_it_obj.search([
('applied_on', '=', '0_virtual_room'), ('applied_on', '=', '0_room_type'),
('restriction_id', '=', self.parity_restrictions_id), ('restriction_id', '=', self.parity_restrictions_id),
('virtual_room_id', 'in', (self.hotel_vroom_budget.id, ('room_type_id', 'in', (self.hotel_vroom_budget.id,
self.hotel_vroom_special.id)), self.hotel_vroom_special.id)),
]) ])
rest_ids.sudo(self.user_hotel_manager).unlink() rest_ids.sudo(self.user_hotel_manager).unlink()
@@ -160,7 +160,7 @@ class TestManagementCalendar(TestHotelCalendar):
# CHANGE AVAIL # CHANGE AVAIL
avail_ids = vroom_avail_obj.search([ avail_ids = vroom_avail_obj.search([
('virtual_room_id', 'in', (self.hotel_vroom_budget.id, ('room_type_id', 'in', (self.hotel_vroom_budget.id,
self.hotel_vroom_special.id)), self.hotel_vroom_special.id)),
]) ])
for avail_id in avail_ids: for avail_id in avail_ids:
@@ -183,7 +183,7 @@ class TestManagementCalendar(TestHotelCalendar):
# REMOVE AVAIL # REMOVE AVAIL
avail_ids = vroom_avail_obj.search([ avail_ids = vroom_avail_obj.search([
('virtual_room_id', 'in', (self.hotel_vroom_budget.id, ('room_type_id', 'in', (self.hotel_vroom_budget.id,
self.hotel_vroom_special.id)), self.hotel_vroom_special.id)),
]) ])
avail_ids.sudo(self.user_hotel_manager).unlink() avail_ids.sudo(self.user_hotel_manager).unlink()

View File

@@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<odoo> <odoo>
<record id="virtual_room_view_form" model="ir.ui.view"> <record id="room_type_view_form" model="ir.ui.view">
<field name="model">hotel.room.type</field> <field name="model">hotel.room.type</field>
<field name="inherit_id" ref="hotel.view_hotel_room_type_form" /> <field name="inherit_id" ref="hotel.view_hotel_room_type_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">

View File

@@ -1,33 +1,11 @@
# -*- coding: utf-8 -*- # Copyright 2018 Dario Lodeiros
############################################################################## # Copyright 2018 Alexandre Díaz <dev@redneboa.es>
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# OpenERP, Open Source Management Solution
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
# Alexandre Díaz <dev@redneboa.es>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import pytz
import time import time
import logging import logging
from decimal import Decimal from datetime import timedelta
from dateutil.relativedelta import relativedelta from openerp.exceptions import ValidationError
from datetime import datetime, timedelta, date
from openerp.exceptions import except_orm, UserError, ValidationError
from openerp.tools import ( from openerp.tools import (
misc,
DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATE_FORMAT,
DEFAULT_SERVER_DATETIME_FORMAT) DEFAULT_SERVER_DATETIME_FORMAT)
from openerp import models, fields, api, _ from openerp import models, fields, api, _
@@ -48,7 +26,7 @@ class FolioWizard(models.TransientModel):
def _get_default_checkin(self): def _get_default_checkin(self):
folio = False folio = False
default_arrival_hour = self.env['ir.default'].sudo().get( default_arrival_hour = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_arrival_hour') 'res.config.settings', 'default_arrival_hour')
if 'folio_id' in self._context: if 'folio_id' in self._context:
folio = self.env['hotel.folio'].search([ folio = self.env['hotel.folio'].search([
('id', '=', self._context['folio_id']) ('id', '=', self._context['folio_id'])
@@ -76,7 +54,7 @@ class FolioWizard(models.TransientModel):
('id', '=', self._context['folio_id']) ('id', '=', self._context['folio_id'])
]) ])
if folio and folio.room_lines: if folio and folio.room_lines:
return folio.room_lines[0].checkout return folio.room_lines[0].checkout
else: else:
tz_hotel = self.env['ir.default'].sudo().get( tz_hotel = self.env['ir.default'].sudo().get(
'res.config.settings', 'tz_hotel') 'res.config.settings', 'tz_hotel')
@@ -103,8 +81,8 @@ class FolioWizard(models.TransientModel):
'folio_wizard_id', 'folio_wizard_id',
string="Resevations") string="Resevations")
service_wizard_ids = fields.One2many('hotel.service.wizard', service_wizard_ids = fields.One2many('hotel.service.wizard',
'folio_wizard_id', 'folio_wizard_id',
string='Services') string='Services')
total = fields.Float('Total', compute='_computed_total') total = fields.Float('Total', compute='_computed_total')
confirm = fields.Boolean('Confirm Reservations', default="1") confirm = fields.Boolean('Confirm Reservations', default="1")
autoassign = fields.Boolean('Autoassign', default="1") autoassign = fields.Boolean('Autoassign', default="1")
@@ -112,25 +90,25 @@ class FolioWizard(models.TransientModel):
('door', 'Door'), ('door', 'Door'),
('mail', 'Mail'), ('mail', 'Mail'),
('phone', 'Phone') ('phone', 'Phone')
], string='Sales Channel', default=_get_default_channel_type) ], string='Sales Channel', default=_get_default_channel_type)
virtual_room_wizard_ids = fields.Many2many('hotel.virtual.room.wizard', room_type_wizard_ids = fields.Many2many('hotel.room.type.wizard',
string="Virtual Rooms") string="Virtual Rooms")
call_center = fields.Boolean(default=_get_default_center_user) call_center = fields.Boolean(default=_get_default_center_user)
def assign_rooms(self): def assign_rooms(self):
self.assign=True self.assign = True
@api.onchange('autoassign') @api.onchange('autoassign')
def create_reservations(self): def create_reservations(self):
self.ensure_one() self.ensure_one()
total = 0 total = 0
cmds = [] cmds = []
for line in self.virtual_room_wizard_ids: for line in self.room_type_wizard_ids:
if line.rooms_num == 0: if line.rooms_num == 0:
continue continue
if line.rooms_num > line.max_rooms: if line.rooms_num > line.max_rooms:
raise ValidationError(_("Too many rooms!")) raise ValidationError(_("Too many rooms!"))
elif line.virtual_room_id: elif line.room_type_id:
checkout_dt = date_utils.get_datetime(line.checkout) checkout_dt = date_utils.get_datetime(line.checkout)
occupied = self.env['hotel.reservation'].occupied( occupied = self.env['hotel.reservation'].occupied(
line.checkin, line.checkin,
@@ -138,15 +116,15 @@ class FolioWizard(models.TransientModel):
rooms_occupied = occupied.mapped('product_id.id') rooms_occupied = occupied.mapped('product_id.id')
free_rooms = self.env['hotel.room'].search([ free_rooms = self.env['hotel.room'].search([
('product_id.id', 'not in', rooms_occupied), ('product_id.id', 'not in', rooms_occupied),
('price_virtual_room.id', '=', line.virtual_room_id.id)], ('price_room_type.id', '=', line.room_type_id.id)
order='sequence', limit=line.rooms_num) ], order='sequence', limit=line.rooms_num)
room_ids = free_rooms.mapped('product_id.id') room_ids = free_rooms.mapped('product_id.id')
product_list = self.env['product.product'].search([ product_list = self.env['product.product'].search([
('id', 'in', room_ids) ('id', 'in', room_ids)
]) ])
nights = days_diff = date_utils.date_diff(line.checkin, nights = date_utils.date_diff(line.checkin,
line.checkout, line.checkout,
hours=False) hours=False)
hotel_tz = self.env['ir.default'].sudo().get( hotel_tz = self.env['ir.default'].sudo().get(
'res.config.settings', 'res.config.settings',
'hotel_tz') 'hotel_tz')
@@ -159,11 +137,10 @@ class FolioWizard(models.TransientModel):
if pricelist_id: if pricelist_id:
pricelist_id = int(pricelist_id) pricelist_id = int(pricelist_id)
res_price = 0 res_price = 0
res_partner = self.partner_id or self.env['res.partner'].browse('1')
for i in range(0, nights): for i in range(0, nights):
ndate = start_date_dt + timedelta(days=i) ndate = start_date_dt + timedelta(days=i)
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT) ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
prod = line.virtual_room_id.product_id.with_context( prod = line.room_type_id.product_id.with_context(
lang=self.partner_id.lang, lang=self.partner_id.lang,
partner=self.partner_id.id, partner=self.partner_id.id,
quantity=1, quantity=1,
@@ -177,17 +154,17 @@ class FolioWizard(models.TransientModel):
res_price = res_price - (res_price * line.discount)/100 res_price = res_price - (res_price * line.discount)/100
total += res_price total += res_price
cmds.append((0, False, { cmds.append((0, False, {
'checkin': line.checkin, 'checkin': line.checkin,
'checkout': line.checkout, 'checkout': line.checkout,
'discount': line.discount, 'discount': line.discount,
'product_id': room.id, 'product_id': room.id,
'nights': nights, 'nights': nights,
'adults': adults, 'adults': adults,
'children': 0, 'children': 0,
'virtual_room_id': line.virtual_room_id, 'room_type_id': line.room_type_id,
'price': res_price, 'price': res_price,
'amount_reservation': res_price 'amount_reservation': res_price
})) }))
self.reservation_wizard_ids = cmds self.reservation_wizard_ids = cmds
self.total = total self.total = total
@@ -201,7 +178,6 @@ class FolioWizard(models.TransientModel):
@param self: object pointer @param self: object pointer
''' '''
self.ensure_one() self.ensure_one()
now_utc_dt = date_utils.now()
if not self.checkin: if not self.checkin:
self.checkin = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT) self.checkin = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
if not self.checkout: if not self.checkout:
@@ -217,36 +193,35 @@ class FolioWizard(models.TransientModel):
dpt_hour = self.env['ir.default'].sudo().get( dpt_hour = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_departure_hour') 'res.config.settings', 'default_departure_hour')
checkout_str = (chkin_utc_dt + timedelta(days=1)).strftime( checkout_str = (chkin_utc_dt + timedelta(days=1)).strftime(
DEFAULT_SERVER_DATE_FORMAT) DEFAULT_SERVER_DATE_FORMAT)
checkout_str = "%s %s:00" % (checkout_str, dpt_hour) checkout_str = "%s %s:00" % (checkout_str, dpt_hour)
checkout_dt = date_utils.get_datetime(checkout_str, stz=tz) checkout_dt = date_utils.get_datetime(checkout_str, stz=tz)
checkout_utc_dt = date_utils.dt_as_timezone(checkout_dt, 'UTC') checkout_utc_dt = date_utils.dt_as_timezone(checkout_dt, 'UTC')
self.checkout = checkout_utc_dt.strftime( self.checkout = checkout_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
DEFAULT_SERVER_DATETIME_FORMAT)
checkout_dt = date_utils.get_datetime(self.checkout, stz=tz) checkout_dt = date_utils.get_datetime(self.checkout, stz=tz)
# Reservation end day count as free day. Not check it # Reservation end day count as free day. Not check it
checkout_dt -= timedelta(days=1) checkout_dt -= timedelta(days=1)
virtual_room_ids = self.env['hotel.room.type'].search([]) room_type_ids = self.env['hotel.room.type'].search([])
virtual_rooms = [] room_types = []
for virtual in virtual_room_ids: for room_type in room_type_ids:
virtual_rooms.append((0, False, { room_types.append((0, False, {
'virtual_room_id': virtual.id, 'room_type_id': room_type.id,
'checkin': self.checkin, 'checkin': self.checkin,
'checkout': self.checkout, 'checkout': self.checkout,
'folio_wizard_id': self.id, 'folio_wizard_id': self.id,
})) }))
self.virtual_room_wizard_ids = virtual_rooms self.room_type_wizard_ids = room_types
for virtual in self.virtual_room_wizard_ids: for room_type in self.room_type_wizard_ids:
virtual.update_price() room_type.update_price()
@api.depends('virtual_room_wizard_ids','reservation_wizard_ids','service_wizard_ids') @api.depends('room_type_wizard_ids','reservation_wizard_ids','service_wizard_ids')
def _computed_total(self): def _computed_total(self):
total = 0 total = 0
for line in self.service_wizard_ids: for line in self.service_wizard_ids:
total += line.price_total total += line.price_total
if not self.reservation_wizard_ids: if not self.reservation_wizard_ids:
for line in self.virtual_room_wizard_ids: for line in self.room_type_wizard_ids:
total += line.total_price total += line.total_price
self.total = total self.total = total
else: else:
@@ -258,36 +233,36 @@ class FolioWizard(models.TransientModel):
def create_folio(self): def create_folio(self):
self.ensure_one() self.ensure_one()
if not self.partner_id: if not self.partner_id:
raise ValidationError(_("We need know the customer!")) raise ValidationError(_("We need know the customer!"))
reservations = [(5, False, False)] reservations = [(5, False, False)]
services = [(5, False, False)] services = [(5, False, False)]
if self.autoassign == True: if self.autoassign == True:
self.create_reservations() self.create_reservations()
for line in self.reservation_wizard_ids: for line in self.reservation_wizard_ids:
reservations.append((0, False, { reservations.append((0, False, {
'product_id': line.product_id.id, 'product_id': line.product_id.id,
'adults': line.adults, 'adults': line.adults,
'children': line.children, 'children': line.children,
'checkin': line.checkin, 'checkin': line.checkin,
'checkout': line.checkout, 'checkout': line.checkout,
'discount': line.discount, 'discount': line.discount,
'virtual_room_id': line.virtual_room_id.id, 'room_type_id': line.room_type_id.id,
'to_read': line.to_read, #REFACT: wubook module 'to_read': line.to_read, #REFACT: wubook module
'to_assign': line.to_assign, 'to_assign': line.to_assign,
})) }))
for line in self.service_wizard_ids: for line in self.service_wizard_ids:
services.append((0, False, { services.append((0, False, {
'product_id': line.product_id.id, 'product_id': line.product_id.id,
'discount': line.discount, 'discount': line.discount,
'price_unit': line.price_unit, 'price_unit': line.price_unit,
'product_uom_qty': line.product_uom_qty, 'product_uom_qty': line.product_uom_qty,
})) }))
vals = { vals = {
'partner_id': self.partner_id.id, 'partner_id': self.partner_id.id,
'channel_type': self.channel_type, 'channel_type': self.channel_type,
'room_lines': reservations, 'room_lines': reservations,
'service_lines': services, 'service_lines': services,
} }
newfol = self.env['hotel.folio'].create(vals) newfol = self.env['hotel.folio'].create(vals)
for room in newfol.room_lines: for room in newfol.room_lines:
room.on_change_checkin_checkout_product_id() room.on_change_checkin_checkout_product_id()
@@ -302,8 +277,9 @@ class FolioWizard(models.TransientModel):
action = {'type': 'ir.actions.act_window_close'} action = {'type': 'ir.actions.act_window_close'}
return action return action
class VirtualRoomWizars(models.TransientModel):
_name = 'hotel.virtual.room.wizard' class HotelRoomTypeWizards(models.TransientModel):
_name = 'hotel.room.type.wizard'
@api.multi @api.multi
def _get_default_checkin(self): def _get_default_checkin(self):
@@ -313,8 +289,8 @@ class VirtualRoomWizars(models.TransientModel):
def _get_default_checkout(self): def _get_default_checkout(self):
return self.folio_wizard_id.checkout return self.folio_wizard_id.checkout
virtual_room_id = fields.Many2one('hotel.room.type', room_type_id = fields.Many2one('hotel.room.type',
string="Virtual Rooms") string="Virtual Rooms")
rooms_num = fields.Integer('Number of Rooms') rooms_num = fields.Integer('Number of Rooms')
max_rooms = fields.Integer('Max', compute="_compute_max") max_rooms = fields.Integer('Max', compute="_compute_max")
price = fields.Float(string='Price by Room') price = fields.Float(string='Price by Room')
@@ -346,15 +322,15 @@ class VirtualRoomWizars(models.TransientModel):
date_end = date_utils.get_datetime(res.checkout) date_end = date_utils.get_datetime(res.checkout)
date_diff = date_utils.date_diff(date_start, date_end, hours=False) date_diff = date_utils.date_diff(date_start, date_end, hours=False)
minstay_restrictions = self.env['hotel.room.type.restriction.item'].search([ minstay_restrictions = self.env['hotel.room.type.restriction.item'].search([
('virtual_room_id','=',res.virtual_room_id.id), ('room_type_id','=',res.room_type_id.id),
]) ])
avail_restrictions = self.env['hotel.room.type.availability'].search([ avail_restrictions = self.env['hotel.room.type.availability'].search([
('virtual_room_id','=',res.virtual_room_id.id) ('room_type_id','=',res.room_type_id.id)
]) ])
real_max = len(res.virtual_room_id.check_availability_virtual_room( real_max = len(res.room_type_id.check_availability_room(
res.checkin, res.checkin,
res.checkout, res.checkout,
res.virtual_room_id.id)) res.room_type_id.id))
avail = 100000 avail = 100000
min_stay = 0 min_stay = 0
dates = [] dates = []
@@ -364,67 +340,59 @@ class VirtualRoomWizars(models.TransientModel):
dates.append(ndate_str) dates.append(ndate_str)
if minstay_restrictions: if minstay_restrictions:
date_min_days = minstay_restrictions.filtered( date_min_days = minstay_restrictions.filtered(
lambda r: r.date_start <= ndate_str and \ lambda r: r.date_start <= ndate_str and \
r.date_end >= ndate_str).min_stay r.date_end >= ndate_str).min_stay
if date_min_days > min_stay: if date_min_days > min_stay:
min_stay = date_min_days min_stay = date_min_days
if user.has_group('hotel.group_hotel_call'): if user.has_group('hotel.group_hotel_call'):
if avail_restrictions: if avail_restrictions:
max_avail = avail_restrictions.filtered( max_avail = avail_restrictions.filtered(
lambda r: r.date == ndate_str).wmax_avail lambda r: r.date == ndate_str).wmax_avail
if max_avail < avail: if max_avail < avail:
avail = min(max_avail, real_max) avail = min(max_avail, real_max)
else: else:
avail = real_max avail = real_max
if avail < 100000 and avail > 0: if 100000 < avail > 0:
res.max_rooms = avail res.max_rooms = avail
else: else:
res.max_rooms = 0 res.max_rooms = 0
if min_stay > 0: if min_stay > 0:
res.min_stay = min_stay res.min_stay = min_stay
@api.onchange('rooms_num', 'discount', 'price','virtual_room_id', @api.onchange('rooms_num', 'discount', 'price', 'room_type_id', 'checkin', 'checkout')
'checkin','checkout')
def update_price(self): def update_price(self):
for line in self: for record in self:
now_utc_dt = date_utils.now() checkin = record.checkin or record.folio_wizard_id.checkin
if not self.checkin: checkout = record.checkout or record.folio_wizard_id.checkout
self.checkin = self.folio_wizard_id.checkin if record.rooms_num > record.max_rooms:
if not self.checkout:
self.checkout = self.folio_wizard_id.checkout
if self.rooms_num > self.max_rooms:
raise ValidationError(_("There are not enough rooms!")) raise ValidationError(_("There are not enough rooms!"))
# UTC -> Hotel tz # UTC -> Hotel tz
tz = self.env['ir.default'].sudo().get('res.config.settings', tz = self.env['ir.default'].sudo().get('res.config.settings',
'tz_hotel') 'tz_hotel')
chkin_utc_dt = date_utils.get_datetime(self.checkin) chkin_utc_dt = date_utils.get_datetime(checkin)
chkout_utc_dt = date_utils.get_datetime(self.checkout) chkout_utc_dt = date_utils.get_datetime(checkout)
if chkin_utc_dt >= chkout_utc_dt: if chkin_utc_dt >= chkout_utc_dt:
dpt_hour = self.env['ir.default'].sudo().get( dpt_hour = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_departure_hour') 'res.config.settings', 'default_departure_hour')
checkout_str = (chkin_utc_dt + timedelta(days=1)).strftime( checkout_str = (chkin_utc_dt + timedelta(days=1)).strftime(
DEFAULT_SERVER_DATE_FORMAT) DEFAULT_SERVER_DATE_FORMAT)
checkout_str = "%s %s:00" % (checkout_str, dpt_hour) checkout_str = "%s %s:00" % (checkout_str, dpt_hour)
checkout_dt = date_utils.get_datetime(checkout_str, stz=tz) checkout_dt = date_utils.get_datetime(checkout_str, stz=tz)
checkout_utc_dt = date_utils.dt_as_timezone(checkout_dt, 'UTC') checkout_utc_dt = date_utils.dt_as_timezone(checkout_dt, 'UTC')
self.checkout = checkout_utc_dt.strftime( checkout = checkout_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
DEFAULT_SERVER_DATETIME_FORMAT) checkout_dt = date_utils.get_datetime(checkout, stz=tz)
checkout_dt = date_utils.get_datetime(self.checkout, stz=tz)
# Reservation end day count as free day. Not check it # Reservation end day count as free day. Not check it
checkout_dt -= timedelta(days=1) checkout_dt -= timedelta(days=1)
nights = days_diff = date_utils.date_diff(self.checkin, nights = date_utils.date_diff(checkin, checkout, hours=False)
self.checkout, start_date_dt = date_utils.dt_as_timezone(chkin_utc_dt, tz)
hours=False)
start_date_dt = date_utils.dt_as_timezone(chkin_utc_dt,
tz)
# Reservation end day count as free day. Not check it # Reservation end day count as free day. Not check it
checkout_dt -= timedelta(days=1) checkout_dt -= timedelta(days=1)
pricelist_id = self.env['ir.default'].sudo().get( pricelist_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'parity_pricelist_id') 'res.config.settings', 'parity_pricelist_id')
if pricelist_id: if pricelist_id:
pricelist_id = int(pricelist_id) pricelist_id = int(pricelist_id)
@@ -432,24 +400,31 @@ class VirtualRoomWizars(models.TransientModel):
for i in range(0, nights): for i in range(0, nights):
ndate = start_date_dt + timedelta(days=i) ndate = start_date_dt + timedelta(days=i)
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT) ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
prod = self.virtual_room_id.product_id.with_context( prod = record.room_type_id.product_id.with_context(
lang=self.folio_wizard_id.partner_id.lang, lang=record.folio_wizard_id.partner_id.lang,
partner=self.folio_wizard_id.partner_id.id, partner=record.folio_wizard_id.partner_id.id,
quantity=1, quantity=1,
date=ndate_str, date=ndate_str,
pricelist=pricelist_id, pricelist=pricelist_id,
uom=self.virtual_room_id.product_id.uom_id.id) uom=record.room_type_id.product_id.uom_id.id)
res_price += prod.price res_price += prod.price
self.price = res_price - (res_price * self.discount)/100
self.total_price = self.rooms_num * self.price price = (res_price * record.discount) * 0.01
self.amount_reservation = self.total_price total_price = record.rooms_num * price
record.write({
'checkin': checkin,
'checkout': checkout,
'price': price,
'total_price': total_price,
'amount_reservation': total_price,
})
class ReservationWizard(models.TransientModel): class ReservationWizard(models.TransientModel):
_name = 'hotel.reservation.wizard' _name = 'hotel.reservation.wizard'
product_id = fields.Many2one('product.product', product_id = fields.Many2one('product.product',
string="Virtual Rooms") string="Room Types")
folio_wizard_id = fields.Many2one('hotel.folio.wizard') folio_wizard_id = fields.Many2one('hotel.folio.wizard')
@@ -459,9 +434,9 @@ class ReservationWizard(models.TransientModel):
help='Number of children there in guest list.') help='Number of children there in guest list.')
checkin = fields.Datetime('Check In', required=True) checkin = fields.Datetime('Check In', required=True)
checkout = fields.Datetime('Check Out', required=True) checkout = fields.Datetime('Check Out', required=True)
virtual_room_id = fields.Many2one('hotel.room.type', room_type_id = fields.Many2one('hotel.room.type',
string='Virtual Room Type', string='Virtual Room Type',
required=True) required=True)
nights = fields.Integer('Nights', readonly=True) nights = fields.Integer('Nights', readonly=True)
price = fields.Float(string='Total') price = fields.Float(string='Total')
amount_reservation = fields.Float(string='Total', readonly=True) amount_reservation = fields.Float(string='Total', readonly=True)
@@ -483,11 +458,11 @@ class ReservationWizard(models.TransientModel):
for line in self: for line in self:
if line.checkin and line.checkout: if line.checkin and line.checkout:
room = self.env['hotel.room'].search([ room = self.env['hotel.room'].search([
('product_id.id','=',line.product_id.id) ('product_id.id', '=', line.product_id.id)
]) ])
if line.adults == 0: if line.adults == 0:
line.adults = room.capacity line.adults = room.capacity
line.virtual_room_id = room.price_virtual_room.id line.room_type_id = room.price_room_type.id
checkout_dt = date_utils.get_datetime(line.checkout) checkout_dt = date_utils.get_datetime(line.checkout)
checkout_dt -= timedelta(days=1) checkout_dt -= timedelta(days=1)
occupied = self.env['hotel.reservation'].occupied( occupied = self.env['hotel.reservation'].occupied(
@@ -495,10 +470,11 @@ class ReservationWizard(models.TransientModel):
checkout_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)) checkout_dt.strftime(DEFAULT_SERVER_DATE_FORMAT))
rooms_occupied = occupied.mapped('product_id.id') rooms_occupied = occupied.mapped('product_id.id')
if line.product_id.id in rooms_occupied: if line.product_id.id in rooms_occupied:
raise ValidationError(_("This room is occupied!, please, choice other room or change the reservation date")) raise ValidationError(_("This room is occupied!, please, \
choice other room or change the reservation date"))
@api.multi @api.multi
@api.onchange('checkin', 'checkout', 'virtual_room_id', 'discount') @api.onchange('checkin', 'checkout', 'room_type_id', 'discount')
def onchange_dates(self): def onchange_dates(self):
for line in self: for line in self:
if not self.checkin: if not self.checkin:
@@ -512,20 +488,19 @@ class ReservationWizard(models.TransientModel):
start_date_dt = date_utils.dt_as_timezone(start_date_utc_dt, start_date_dt = date_utils.dt_as_timezone(start_date_utc_dt,
hotel_tz) hotel_tz)
if line.virtual_room_id: if line.room_type_id:
pricelist_id = self.env['ir.default'].sudo().get( pricelist_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'parity_pricelist_id') 'res.config.settings', 'parity_pricelist_id')
if pricelist_id: if pricelist_id:
pricelist_id = int(pricelist_id) pricelist_id = int(pricelist_id)
nights = days_diff = date_utils.date_diff(line.checkin, nights = date_utils.date_diff(line.checkin,
line.checkout, line.checkout,
hours=False) hours=False)
res_price = 0 res_price = 0
res_partner = self.partner_id or self.env['res.partner'].browse('1')
for i in range(0, nights): for i in range(0, nights):
ndate = start_date_dt + timedelta(days=i) ndate = start_date_dt + timedelta(days=i)
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT) ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
prod = line.virtual_room_id.product_id.with_context( prod = line.room_type_id.product_id.with_context(
lang=self.partner_id.lang, lang=self.partner_id.lang,
partner=self.partner_id.id, partner=self.partner_id.id,
quantity=1, quantity=1,
@@ -533,10 +508,7 @@ class ReservationWizard(models.TransientModel):
pricelist=pricelist_id, pricelist=pricelist_id,
uom=line.product_id.uom_id.id) uom=line.product_id.uom_id.id)
res_price += prod.price res_price += prod.price
adults = self.env['hotel.room'].search([ res_price = res_price - (res_price * self.discount) * 0.01
('product_id.id', '=', line.product_id.id)
]).capacity
res_price = res_price - (res_price * self.discount)/100
line.amount_reservation = res_price line.amount_reservation = res_price
line.price = res_price line.price = res_price
checkout_dt = date_utils.get_datetime(self.checkout) checkout_dt = date_utils.get_datetime(self.checkout)
@@ -551,34 +523,41 @@ class ReservationWizard(models.TransientModel):
] ]
return {'domain': {'product_id': domain_rooms}} return {'domain': {'product_id': domain_rooms}}
class ServiceWizard(models.TransientModel): class ServiceWizard(models.TransientModel):
_name = 'hotel.service.wizard' _name = 'hotel.service.wizard'
product_id = fields.Many2one('product.product', product_id = fields.Many2one('product.product',
string="Service") string="Service")
folio_wizard_id = fields.Many2one('hotel.folio.wizard') folio_wizard_id = fields.Many2one('hotel.folio.wizard')
discount = fields.Float('discount') discount = fields.Float('discount')
price_unit = fields.Float('Unit Price', required=True, digits=dp.get_precision('Product Price'), default=0.0) price_unit = fields.Float('Unit Price', required=True,
price_total = fields.Float(compute='_compute_amount', string='Subtotal', readonly=True, store=True) digits=dp.get_precision('Product Price'),
product_uom_qty = fields.Float(string='Quantity', digits=dp.get_precision('Product Unit of Measure'), required=True, default=1.0) default=0.0)
price_total = fields.Float(compute='_compute_amount', string='Subtotal',
readonly=True, store=True)
product_uom_qty = fields.Float(string='Quantity',
digits=dp.get_precision('Product Unit of Measure'),
required=True,
default=1.0)
@api.onchange('product_id') @api.onchange('product_id')
def onchange_product_id(self): def onchange_product_id(self):
if self.product_id: if self.product_id:
#TODO change pricelist for partner #TODO change pricelist for partner
pricelist_id = self.env['ir.default'].sudo().get( pricelist_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'parity_pricelist_id') 'res.config.settings', 'parity_pricelist_id')
prod = self.product_id.with_context( prod = self.product_id.with_context(
lang=self.folio_wizard_id.partner_id.lang, lang=self.folio_wizard_id.partner_id.lang,
partner=self.folio_wizard_id.partner_id.id, partner=self.folio_wizard_id.partner_id.id,
quantity=1, quantity=1,
date=fields.Datetime.now(), date=fields.Datetime.now(),
pricelist=pricelist_id, pricelist=pricelist_id,
uom=self.product_id.uom_id.id) uom=self.product_id.uom_id.id)
self.price_unit = prod.price self.price_unit = prod.price
@api.depends('price_unit', 'product_uom_qty', 'discount') @api.depends('price_unit', 'product_uom_qty', 'discount')
def _compute_amount(self): def _compute_amount(self):
for ser in self: for ser in self:
total = (ser.price_unit * ser.product_uom_qty) total = (ser.price_unit * ser.product_uom_qty)
ser.price_total = total - (total * ser.discount) / 100 ser.price_total = total - (total * ser.discount) * 0.01

View File

@@ -19,7 +19,7 @@
</group> </group>
</group> </group>
<group> <group>
<field name="virtual_room_wizard_ids" nolabel="1" <field name="room_type_wizard_ids" nolabel="1"
attrs="{'invisible': [('autoassign','=',False)]}"> attrs="{'invisible': [('autoassign','=',False)]}">
<tree editable="bottom" create="false" delete="false" <tree editable="bottom" create="false" delete="false"
decoration-danger="max_rooms &lt; rooms_num" decoration-danger="max_rooms &lt; rooms_num"
@@ -27,7 +27,7 @@
decoration-success="max_rooms &gt;= rooms_num and rooms_num &gt; 0"> decoration-success="max_rooms &gt;= rooms_num and rooms_num &gt; 0">
<field name="min_stay" /> <field name="min_stay" />
<field name="max_rooms" /> <field name="max_rooms" />
<field name="virtual_room_id" string="Room Type" readonly="1"/> <field name="room_type_id" string="Room Type" readonly="1"/>
<field name="rooms_num" attrs="{'readonly': [('can_confirm','=',False)]}" /> <field name="rooms_num" attrs="{'readonly': [('can_confirm','=',False)]}" />
<field name="checkin" widget="date" /> <field name="checkin" widget="date" />
<field name="checkout" widget="date" /> <field name="checkout" widget="date" />
@@ -50,7 +50,7 @@
nolabel="1" attrs="{'invisible': [('autoassign','=',True)]}"> nolabel="1" attrs="{'invisible': [('autoassign','=',True)]}">
<tree string="Room Line" delete="false" editable="buttom"> <tree string="Room Line" delete="false" editable="buttom">
<field name="product_id" string="Room No" options="{'no_create': True}"/> <field name="product_id" string="Room No" options="{'no_create': True}"/>
<field name="virtual_room_id" options="{'no_create': True}" /> <field name="room_type_id" options="{'no_create': True}" />
<field name="checkin" /> <field name="checkin" />
<field name="checkout" /> <field name="checkout" />
<field name="nights" /> <field name="nights" />

View File

@@ -84,10 +84,10 @@ class HotelReservation(models.Model):
'reserve_color_text': record.reserve_color_text, 'reserve_color_text': record.reserve_color_text,
'splitted': record.splitted, 'splitted': record.splitted,
'parent_reservation': record.parent_reservation and 'parent_reservation': record.parent_reservation and
record.parent_reservation.id or 0, record.parent_reservation.id or 0,
'room_name': record.product_id.name, 'room_name': record.product_id.name,
'partner_phone': record.partner_id.mobile 'partner_phone': record.partner_id.mobile or
or record.partner_id.phone or _('Undefined'), record.partner_id.phone or _('Undefined'),
'state': record.state, 'state': record.state,
'fix_days': record.splitted or record.is_from_ota, 'fix_days': record.splitted or record.is_from_ota,
'overbooking': record.overbooking, 'overbooking': record.overbooking,
@@ -98,6 +98,6 @@ class HotelReservation(models.Model):
@api.multi @api.multi
def confirm(self): def confirm(self):
for record in self: for record in self:
if record.to_assign == True: if record.to_assign:
record.write({'to_read': False, 'to_assign': False}) record.write({'to_read': False, 'to_assign': False})
return super(HotelReservation, self).confirm() return super(HotelReservation, self).confirm()

View File

@@ -41,7 +41,7 @@
<field name="partner_id"/> <field name="partner_id"/>
<field name="splitted" invisible="1" /> <field name="splitted" invisible="1" />
<field name="parent_reservation" invisible="1" /> <field name="parent_reservation" invisible="1" />
<field name="virtual_room_id" string="Reserved Room Type"/> <field name="room_type_id" string="Reserved Room Type"/>
<field name="nights" /> <field name="nights" />
<field name="to_read" invisible="1"/> <field name="to_read" invisible="1"/>
<field name="adults" string="Persons"/> <field name="adults" string="Persons"/>

View File

@@ -25,7 +25,7 @@
'views/general.xml', 'views/general.xml',
'views/inherited_hotel_reservation_views.xml', 'views/inherited_hotel_reservation_views.xml',
'views/inherited_hotel_room_type_views.xml', 'views/inherited_hotel_room_type_views.xml',
'views/inherited_hotel_virtual_room_availability_views.xml', 'views/inherited_hotel_room_type_availability_views.xml',
'views/inherited_hotel_folio_views.xml', 'views/inherited_hotel_folio_views.xml',
'views/inherited_product_pricelist_views.xml', 'views/inherited_product_pricelist_views.xml',
'views/inherited_product_pricelist_item_views.xml', 'views/inherited_product_pricelist_item_views.xml',
@@ -36,8 +36,8 @@
'views/wubook_issue_views.xml', 'views/wubook_issue_views.xml',
'views/channel_hotel_reservation_views.xml', 'views/channel_hotel_reservation_views.xml',
'views/channel_hotel_room_type_views.xml', 'views/channel_hotel_room_type_views.xml',
'views/channel_hotel_virtual_room_availability_views.xml', 'views/channel_hotel_room_type_availability_views.xml',
'views/channel_hotel_virtual_room_restriction_views.xml', 'views/channel_hotel_room_type_restriction_views.xml',
'views/channel_product_pricelist_views.xml', 'views/channel_product_pricelist_views.xml',
'data/menus.xml', 'data/menus.xml',
'data/sequences.xml', 'data/sequences.xml',

View File

@@ -29,11 +29,11 @@ class HotelChannelConnectorExporter(AbstractComponent):
DEFAULT_SERVER_DATE_FORMAT)) DEFAULT_SERVER_DATE_FORMAT))
]) ])
vrooms = vroom_avail_ids.mapped('virtual_room_id') vrooms = vroom_avail_ids.mapped('room_type_id')
avails = [] avails = []
for vroom in vrooms: for vroom in vrooms:
vroom_avails = vroom_avail_ids.filtered( vroom_avails = vroom_avail_ids.filtered(
lambda x: x.virtual_room_id.id == vroom.id) lambda x: x.room_type_id.id == vroom.id)
days = [] days = []
for vroom_avail in vroom_avails: for vroom_avail in vroom_avails:
vroom_avail.with_context({ vroom_avail.with_context({
@@ -139,8 +139,8 @@ class HotelChannelConnectorExporter(AbstractComponent):
('wpushed', '=', False), ('wpushed', '=', False),
('restriction_id', '=', rp.id) ('restriction_id', '=', rp.id)
]) ])
virtual_room_ids = unpushed_rp.mapped('virtual_room_id') room_type_ids = unpushed_rp.mapped('room_type_id')
for vroom in virtual_room_ids: for vroom in room_type_ids:
restrictions[rp.wpid].update({vroom.wrid: []}) restrictions[rp.wpid].update({vroom.wrid: []})
for i in range(0, days_diff): for i in range(0, days_diff):
ndate_dt = date_start + timedelta(days=i) ndate_dt = date_start + timedelta(days=i)

View File

@@ -17,9 +17,9 @@ class HotelChannelConnectorImporter(AbstractComponent):
@api.model @api.model
def _get_room_values_availability(self, vroom_id, date_str, day_vals, set_max_avail): def _get_room_values_availability(self, vroom_id, date_str, day_vals, set_max_avail):
virtual_room_avail_obj = self.env['hotel.room.type.availability'] room_type_avail_obj = self.env['hotel.room.type.availability']
vroom_avail = virtual_room_avail_obj.search([ vroom_avail = room_type_avail_obj.search([
('virtual_room_id', '=', vroom_id), ('room_type_id', '=', vroom_id),
('date', '=', date_str) ('date', '=', date_str)
], limit=1) ], limit=1)
vals = { vals = {
@@ -36,10 +36,10 @@ class HotelChannelConnectorImporter(AbstractComponent):
}).write(vals) }).write(vals)
else: else:
vals.update({ vals.update({
'virtual_room_id': vroom_id, 'room_type_id': vroom_id,
'date': date_str, 'date': date_str,
}) })
virtual_room_avail_obj.with_context({ room_type_avail_obj.with_context({
'wubook_action': False, 'wubook_action': False,
'mail_create_nosubscribe': True, 'mail_create_nosubscribe': True,
}).create(vals) }).create(vals)
@@ -48,8 +48,8 @@ class HotelChannelConnectorImporter(AbstractComponent):
def _get_room_values_restrictions(self, restriction_plan_id, vroom_id, date_str, day_vals): def _get_room_values_restrictions(self, restriction_plan_id, vroom_id, date_str, day_vals):
vroom_restr_item_obj = self.env['hotel.room.type.restriction.item'] vroom_restr_item_obj = self.env['hotel.room.type.restriction.item']
vroom_restr = vroom_restr_item_obj.search([ vroom_restr = vroom_restr_item_obj.search([
('virtual_room_id', '=', vroom_id), ('room_type_id', '=', vroom_id),
('applied_on', '=', '0_virtual_room'), ('applied_on', '=', '0_room_type'),
('date_start', '=', date_str), ('date_start', '=', date_str),
('date_end', '=', date_str), ('date_end', '=', date_str),
('restriction_id', '=', restriction_plan_id), ('restriction_id', '=', restriction_plan_id),
@@ -79,10 +79,10 @@ class HotelChannelConnectorImporter(AbstractComponent):
else: else:
vals.update({ vals.update({
'restriction_id': restriction_plan_id, 'restriction_id': restriction_plan_id,
'virtual_room_id': vroom_id, 'room_type_id': vroom_id,
'date_start': date_str, 'date_start': date_str,
'date_end': date_str, 'date_end': date_str,
'applied_on': '0_virtual_room', 'applied_on': '0_room_type',
}) })
vroom_restr_item_obj.with_context({ vroom_restr_item_obj.with_context({
'wubook_action': False, 'wubook_action': False,
@@ -90,13 +90,13 @@ class HotelChannelConnectorImporter(AbstractComponent):
@api.model @api.model
def _generate_room_values(self, dfrom, dto, values, set_max_avail=False): def _generate_room_values(self, dfrom, dto, values, set_max_avail=False):
virtual_room_restr_obj = self.env['hotel.room.type.restriction'] room_type_restr_obj = self.env['hotel.room.type.restriction']
hotel_virtual_room_obj = self.env['hotel.room.type'] hotel_room_type_obj = self.env['hotel.room.type']
def_restr_plan = virtual_room_restr_obj.search([('wpid', '=', '0')]) def_restr_plan = room_type_restr_obj.search([('wpid', '=', '0')])
_logger.info("==== ROOM VALUES (%s -- %s)", dfrom, dto) _logger.info("==== ROOM VALUES (%s -- %s)", dfrom, dto)
_logger.info(values) _logger.info(values)
for k_rid, v_rid in values.iteritems(): for k_rid, v_rid in values.iteritems():
vroom = hotel_virtual_room_obj.search([ vroom = hotel_room_type_obj.search([
('wrid', '=', k_rid) ('wrid', '=', k_rid)
], limit=1) ], limit=1)
if vroom: if vroom:
@@ -159,7 +159,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
'wstatus': wstatus, 'wstatus': wstatus,
'to_read': True, 'to_read': True,
'state': is_cancellation and 'cancelled' or 'draft', 'state': is_cancellation and 'cancelled' or 'draft',
'virtual_room_id': vroom.id, 'room_type_id': vroom.id,
'splitted': split_booking, 'splitted': split_booking,
'wbook_json': json.dumps(book), 'wbook_json': json.dumps(book),
'wmodified': book['was_modified'] 'wmodified': book['was_modified']
@@ -362,10 +362,10 @@ class HotelChannelConnectorImporter(AbstractComponent):
"Invalid reservation total price! %.2f != %.2f" % (vals['price_unit'], book['amount']), "Invalid reservation total price! %.2f != %.2f" % (vals['price_unit'], book['amount']),
'', wid=book['reservation_code']) '', wid=book['reservation_code'])
free_rooms = hotel_vroom_obj.check_availability_virtual_room( free_rooms = hotel_vroom_obj.check_availability_room(
checkin_str, checkin_str,
checkout_str, checkout_str,
virtual_room_id=vroom.id, room_type_id=vroom.id,
notthis=used_rooms) notthis=used_rooms)
if any(free_rooms): if any(free_rooms):
vals.update({ vals.update({
@@ -515,7 +515,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
@api.model @api.model
def _generate_pricelist_items(self, channel_plan_id, date_from, date_to, plan_prices): def _generate_pricelist_items(self, channel_plan_id, date_from, date_to, plan_prices):
hotel_virtual_room_obj = self.env['hotel.room.type'] hotel_room_type_obj = self.env['hotel.room.type']
pricelist = self.env['product.pricelist'].search([ pricelist = self.env['product.pricelist'].search([
('wpid', '=', channel_plan_id) ('wpid', '=', channel_plan_id)
], limit=1) ], limit=1)
@@ -527,7 +527,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
for i in range(0, days_diff): for i in range(0, days_diff):
ndate_dt = dfrom_dt + timedelta(days=i) ndate_dt = dfrom_dt + timedelta(days=i)
for k_rid, v_rid in plan_prices.iteritems(): for k_rid, v_rid in plan_prices.iteritems():
vroom = hotel_virtual_room_obj.search([ vroom = hotel_room_type_obj.search([
('wrid', '=', k_rid) ('wrid', '=', k_rid)
], limit=1) ], limit=1)
if vroom: if vroom:
@@ -589,7 +589,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
@api.model @api.model
def _generate_restriction_items(self, plan_restrictions): def _generate_restriction_items(self, plan_restrictions):
hotel_virtual_room_obj = self.env['hotel.room.type'] hotel_room_type_obj = self.env['hotel.room.type']
reserv_restriction_obj = self.env['hotel.room.type.restriction'] reserv_restriction_obj = self.env['hotel.room.type.restriction']
restriction_item_obj = self.env['hotel.room.type.restriction.item'] restriction_item_obj = self.env['hotel.room.type.restriction.item']
_logger.info("===== RESTRICTIONS") _logger.info("===== RESTRICTIONS")
@@ -600,7 +600,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
], limit=1) ], limit=1)
if restriction_id: if restriction_id:
for k_rid, v_rid in v_rpid.iteritems(): for k_rid, v_rid in v_rpid.iteritems():
vroom = hotel_virtual_room_obj.search([ vroom = hotel_room_type_obj.search([
('wrid', '=', k_rid) ('wrid', '=', k_rid)
], limit=1) ], limit=1)
if vroom: if vroom:
@@ -614,8 +614,8 @@ class HotelChannelConnectorImporter(AbstractComponent):
DEFAULT_SERVER_DATE_FORMAT)), DEFAULT_SERVER_DATE_FORMAT)),
('date_end', '=', date_dt.strftime( ('date_end', '=', date_dt.strftime(
DEFAULT_SERVER_DATE_FORMAT)), DEFAULT_SERVER_DATE_FORMAT)),
('applied_on', '=', '0_virtual_room'), ('applied_on', '=', '0_room_type'),
('virtual_room_id', '=', vroom.id) ('room_type_id', '=', vroom.id)
], limit=1) ], limit=1)
vals = { vals = {
'closed_arrival': item['closed_arrival'], 'closed_arrival': item['closed_arrival'],
@@ -637,8 +637,8 @@ class HotelChannelConnectorImporter(AbstractComponent):
DEFAULT_SERVER_DATE_FORMAT), DEFAULT_SERVER_DATE_FORMAT),
'date_end': date_dt.strftime( 'date_end': date_dt.strftime(
DEFAULT_SERVER_DATE_FORMAT), DEFAULT_SERVER_DATE_FORMAT),
'applied_on': '0_virtual_room', 'applied_on': '0_room_type',
'virtual_room_id': vroom.id 'room_type_id': vroom.id
}) })
restriction_item_obj.with_context({ restriction_item_obj.with_context({
'wubook_action': False}).create(vals) 'wubook_action': False}).create(vals)

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1"> <odoo noupdate="1">
<record model="ir.sequence" id="seq_vroom_id"> <record model="ir.sequence" id="seq_room_type_id">
<field name="name">Virtual Room Short Code</field> <field name="name">Virtual Room Short Code</field>
<field name="code">hotel.virtual.room</field> <field name="code">hotel.room.type</field>
<field name="prefix"></field> <field name="prefix"></field>
<field name="padding">4</field> <field name="padding">4</field>
</record> </record>

View File

@@ -7,9 +7,9 @@ from . import res_config
from . import hotel_room_type from . import hotel_room_type
from . import product_pricelist from . import product_pricelist
from . import inherited_product_pricelist_item from . import inherited_product_pricelist_item
from . import hotel_virtual_room_restriction from . import hotel_room_type_restriction
from . import inherited_reservation_restriction_item from . import inherited_reservation_restriction_item
from . import hotel_virtual_room_availability from . import hotel_room_type_availability
from . import hotel_reservation from . import hotel_reservation
from . import inherited_hotel_folio from . import inherited_hotel_folio
from . import inherited_res_partner from . import inherited_res_partner

View File

@@ -121,7 +121,7 @@ class HotelRoomType(models.Model):
restriction = self.env['hotel.room.type.restriction.item'].search([ restriction = self.env['hotel.room.type.restriction.item'].search([
('date_start', '=', date), ('date_start', '=', date),
('date_end', '=', date), ('date_end', '=', date),
('virtual_room_id', '=', self.id), ('room_type_id', '=', self.id),
('restriction_id', '=', restriction_plan_id) ('restriction_id', '=', restriction_plan_id)
], limit=1) ], limit=1)
return restriction return restriction

View File

@@ -6,7 +6,7 @@ from odoo.addons.queue_job.job import job, related_action
from odoo.addons.component.core import Component from odoo.addons.component.core import Component
from odoo.addons.component_event import skip_if from odoo.addons.component_event import skip_if
class ChannelHotelVirtualRoomAvailability(models.Model): class ChannelHotelRoomTypeAvailability(models.Model):
_name = 'channel.hotel.room.type.availability' _name = 'channel.hotel.room.type.availability'
_inherit = 'channel.binding' _inherit = 'channel.binding'
_inherits = {'hotel.room.type.availability': 'odoo_id'} _inherits = {'hotel.room.type.availability': 'odoo_id'}
@@ -14,8 +14,8 @@ class ChannelHotelVirtualRoomAvailability(models.Model):
@api.model @api.model
def _default_channel_max_avail(self): def _default_channel_max_avail(self):
if self.virtual_room_id: if self.room_type_id:
return self.virtual_room_id.max_real_rooms return self.room_type_id.max_real_rooms
return -1 return -1
odoo_id = fields.Many2one(comodel_names='product.pricelist', odoo_id = fields.Many2one(comodel_names='product.pricelist',
@@ -31,10 +31,10 @@ class ChannelHotelVirtualRoomAvailability(models.Model):
@api.constrains('channel_max_avail') @api.constrains('channel_max_avail')
def _check_wmax_avail(self): def _check_wmax_avail(self):
for record in self: for record in self:
if record.channel_max_avail > record.virtual_room_id.total_rooms_count: if record.channel_max_avail > record.room_type_id.total_rooms_count:
raise ValidationError(_("max avail for channel can't be high \ raise ValidationError(_("max avail for channel can't be high \
than toal rooms \ than toal rooms \
count: %d") % record.virtual_room_id.total_rooms_count) count: %d") % record.room_type_id.total_rooms_count)
@job(default_channel='root.channel') @job(default_channel='root.channel')
@related_action(action='related_action_unwrap_binding') @related_action(action='related_action_unwrap_binding')
@@ -46,40 +46,40 @@ class ChannelHotelVirtualRoomAvailability(models.Model):
adapter = work.component(usage='backend.adapter') adapter = work.component(usage='backend.adapter')
date_dt = date_utils.get_datetime(self.date) date_dt = date_utils.get_datetime(self.date)
adapter.update_availability([{ adapter.update_availability([{
'id': self.virtual_room_id.channel_room_id, 'id': self.room_type_id.channel_room_id,
'days': [{ 'days': [{
'date': date_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT), 'date': date_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
'avail': self.avail, 'avail': self.avail,
}], }],
}]) }])
class HotelVirtualRoomAvailability(models.Model): class HotelRoomTypeAvailability(models.Model):
_inherit = 'hotel.room.type.availability' _inherit = 'hotel.room.type.availability'
channel_bind_ids = fields.One2many( channel_bind_ids = fields.One2many(
comodel_name='channel.hotel.room.type.availability', comodel_name='channel.hotel.room.type.availability',
inverse_name='odoo_id', inverse_name='odoo_id',
string='Hotel Virtual Room Availability Connector Bindings') string='Hotel Room Type Availability Connector Bindings')
@api.constrains('avail') @api.constrains('avail')
def _check_avail(self): def _check_avail(self):
vroom_obj = self.env['hotel.virtual.room'] vroom_obj = self.env['hotel.virtual.room']
issue_obj = self.env['hotel.channel.connector.issue'] issue_obj = self.env['hotel.channel.connector.issue']
for record in self: for record in self:
cavail = len(vroom_obj.check_availability_virtual_room( cavail = len(vroom_obj.check_availability_room(
record.date, record.date,
record.date, record.date,
virtual_room_id=record.virtual_room_id.id)) room_type_id=record.room_type_id.id))
max_avail = min(cavail, record.virtual_room_id.total_rooms_count) max_avail = min(cavail, record.room_type_id.total_rooms_count)
if record.avail > max_avail: if record.avail > max_avail:
issue_obj.sudo().create({ issue_obj.sudo().create({
'section': 'avail', 'section': 'avail',
'message': _(r"The new availability can't be greater than \ 'message': _(r"The new availability can't be greater than \
the actual availability \ the actual availability \
\n[%s]\nInput: %d\Limit: %d") % (record.virtual_room_id.name, \n[%s]\nInput: %d\Limit: %d") % (record.room_type_id.name,
record.avail, record.avail,
record), record),
'wid': record.virtual_room_id.wrid, 'wid': record.room_type_id.wrid,
'date_start': record.date, 'date_start': record.date,
'date_end': record.date, 'date_end': record.date,
}) })
@@ -87,10 +87,10 @@ class HotelVirtualRoomAvailability(models.Model):
self._event('on_fix_channel_availability').notify(record) self._event('on_fix_channel_availability').notify(record)
return super(HotelVirtualRoomAvailability, self)._check_avail() return super(HotelVirtualRoomAvailability, self)._check_avail()
@api.onchange('virtual_room_id') @api.onchange('room_type_id')
def onchange_virtual_room_id(self): def onchange_room_type_id(self):
if self.virtual_room_id: if self.room_type_id:
self.channel_max_avail = self.virtual_room_id.max_real_rooms self.channel_max_avail = self.room_type_id.max_real_rooms
@api.multi @api.multi
def write(self, vals): def write(self, vals):
@@ -105,7 +105,7 @@ class HotelVirtualRoomAvailability(models.Model):
date_diff = date_utils.date_diff(checkin, checkout, hours=False) date_diff = date_utils.date_diff(checkin, checkout, hours=False)
vroom_obj = self.env['hotel.virtual.room'] vroom_obj = self.env['hotel.virtual.room']
virtual_room_avail_obj = self.env['hotel.room.type.availability'] room_type_avail_obj = self.env['hotel.room.type.availability']
vrooms = vroom_obj.search([ vrooms = vroom_obj.search([
('room_ids.product_id', '=', product_id) ('room_ids.product_id', '=', product_id)
@@ -115,29 +115,29 @@ class HotelVirtualRoomAvailability(models.Model):
for i in range(0, date_diff): for i in range(0, date_diff):
ndate_dt = date_start + timedelta(days=i) ndate_dt = date_start + timedelta(days=i)
ndate_str = ndate_dt.strftime(DEFAULT_SERVER_DATE_FORMAT) ndate_str = ndate_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
avail = len(vroom_obj.check_availability_virtual_room( avail = len(vroom_obj.check_availability_room(
ndate_str, ndate_str,
ndate_str, ndate_str,
virtual_room_id=vroom.id)) room_type_id=vroom.id))
max_avail = vroom.max_real_rooms max_avail = vroom.max_real_rooms
vroom_avail_id = virtual_room_avail_obj.search([ vroom_avail_id = room_type_avail_obj.search([
('virtual_room_id', '=', vroom.id), ('room_type_id', '=', vroom.id),
('date', '=', ndate_str)], limit=1) ('date', '=', ndate_str)], limit=1)
if vroom_avail_id and vroom_avail_id.channel_max_avail >= 0: if vroom_avail_id and vroom_avail_id.channel_max_avail >= 0:
max_avail = vroom_avail_id.channel_max_avail max_avail = vroom_avail_id.channel_max_avail
avail = max( avail = max(
min(avail, vroom.total_rooms_count, max_avail), 0) min(avail, vroom.total_rooms_count, max_avail), 0)
if vroom_avail_id: if vroom_avail_id:
vroom_avail_id.write({'avail': avail}) vroom_avail_id.write({'avail': avail})
else: else:
virtual_room_avail_obj.create({ room_type_avail_obj.create({
'virtual_room_id': vroom.id, 'room_type_id': vroom.id,
'date': ndate_str, 'date': ndate_str,
'avail': avail, 'avail': avail,
}) })
class ChannelBindingHotelVirtualRoomAvailabilityListener(Component): class ChannelBindingHotelRoomTypeAvailabilityListener(Component):
_name = 'channel.binding.hotel.room.type.availability.listener' _name = 'channel.binding.hotel.room.type.availability.listener'
_inherit = 'base.connector.listener' _inherit = 'base.connector.listener'
_apply_on = ['channel.hotel.room.type.availability'] _apply_on = ['channel.hotel.room.type.availability']

View File

@@ -6,11 +6,11 @@ from odoo.addons.queue_job.job import job, related_action
from odoo.addons.component.core import Component from odoo.addons.component.core import Component
from odoo.addons.component_event import skip_if from odoo.addons.component_event import skip_if
class ChannelHotelVirtualRoomRestriction(models.Model): class ChannelHotelRoomTypeRestriction(models.Model):
_name = 'channel.hotel.room.type.restriction' _name = 'channel.hotel.room.type.restriction'
_inherit = 'channel.binding' _inherit = 'channel.binding'
_inherits = {'hotel.room.type.restriction': 'odoo_id'} _inherits = {'hotel.room.type.restriction': 'odoo_id'}
_description = 'Channel Hotel Virtual Room Restriction' _description = 'Channel Hotel Room Type Restriction'
odoo_id = fields.Many2one(comodel_names='hotel.room.type.restriction', odoo_id = fields.Many2one(comodel_names='hotel.room.type.restriction',
string='Hotel Virtual Room Restriction', string='Hotel Virtual Room Restriction',
@@ -70,7 +70,7 @@ class ChannelHotelVirtualRoomRestriction(models.Model):
importer = work.component(usage='channel.importer') importer = work.component(usage='channel.importer')
return importer.import_restriction_plans() return importer.import_restriction_plans()
class HotelVirtualRoomRestriction(models.Model): class HotelRoomTypeRestriction(models.Model):
_inherit = 'hotel.room.type.restriction' _inherit = 'hotel.room.type.restriction'
channel_bind_ids = fields.One2many( channel_bind_ids = fields.One2many(
@@ -92,7 +92,7 @@ class HotelVirtualRoomRestriction(models.Model):
names.append((name[0], name[1])) names.append((name[0], name[1]))
return names return names
class ChannelBindingHotelVirtualRoomRestrictionListener(Component): class ChannelBindingHotelRoomTypeRestrictionListener(Component):
_name = 'channel.binding.hotel.room.type.restriction.listener' _name = 'channel.binding.hotel.room.type.restriction.listener'
_inherit = 'base.connector.listener' _inherit = 'base.connector.listener'
_apply_on = ['channel.hotel.room.type.restriction'] _apply_on = ['channel.hotel.room.type.restriction']

View File

@@ -48,11 +48,11 @@ class HotelFolio(models.Model):
dates = rline.get_real_checkin_checkout() dates = rline.get_real_checkin_checkout()
vals = { vals = {
'num': len( 'num': len(
self.room_lines.filtered(lambda r: r.get_real_checkin_checkout()[0] == dates[0] and r.get_real_checkin_checkout()[1] == dates[1] and r.virtual_room_id.id == rline.virtual_room_id.id and (r.to_send or import_all) and not r.parent_reservation and r.state == rline.state and ((r.state == 'cancelled' and not r.channel_modified) or r.state != 'cancelled')) self.room_lines.filtered(lambda r: r.get_real_checkin_checkout()[0] == dates[0] and r.get_real_checkin_checkout()[1] == dates[1] and r.room_type_id.id == rline.room_type_id.id and (r.to_send or import_all) and not r.parent_reservation and r.state == rline.state and ((r.state == 'cancelled' and not r.channel_modified) or r.state != 'cancelled'))
), ),
'virtual_room': { 'room_type': {
'id': rline.virtual_room_id.id, 'id': rline.room_type_id.id,
'name': rline.virtual_room_id.name, 'name': rline.room_type_id.name,
}, },
'checkin': dates[0], 'checkin': dates[0],
'checkout': dates[1], 'checkout': dates[1],
@@ -62,13 +62,13 @@ class HotelFolio(models.Model):
} }
founded = False founded = False
for srline in info_grouped: for srline in info_grouped:
if srline['num'] == vals['num'] and srline['virtual_room']['id'] == vals['virtual_room']['id'] and srline['checkin'] == vals['checkin'] and srline['checkout'] == vals['checkout']: if srline['num'] == vals['num'] and srline['room_type']['id'] == vals['room_type']['id'] and srline['checkin'] == vals['checkin'] and srline['checkout'] == vals['checkout']:
founded = True founded = True
break break
if not founded: if not founded:
info_grouped.append(vals) info_grouped.append(vals)
return sorted(sorted(info_grouped, key=lambda k: k['num'], return sorted(sorted(info_grouped, key=lambda k: k['num'],
reverse=True), key=lambda k: k['virtual_room']['id']) reverse=True), key=lambda k: k['room_type']['id'])
@api.depends('room_lines') @api.depends('room_lines')
def _compute_has_cancelled_reservations_to_send(self): def _compute_has_cancelled_reservations_to_send(self):

View File

@@ -122,7 +122,7 @@ class HotelChannelConnectorConfiguration(models.TransientModel):
vroom_restr_it_obj = self.env['hotel.room.type.restriction.item'] vroom_restr_it_obj = self.env['hotel.room.type.restriction.item']
# Secure Wubook Input # Secure Wubook Input
restriction_item_ids = vroom_restr_it_obj.search([ restriction_item_ids = vroom_restr_it_obj.search([
('applied_on', '=', '0_virtual_room'), ('applied_on', '=', '0_room_type'),
('date_start', '<', now_utc_str), ('date_start', '<', now_utc_str),
]) ])
if any(restriction_item_ids): if any(restriction_item_ids):
@@ -132,7 +132,7 @@ class HotelChannelConnectorConfiguration(models.TransientModel):
# Put to push restrictions # Put to push restrictions
restriction_item_ids = vroom_restr_it_obj.search([ restriction_item_ids = vroom_restr_it_obj.search([
('restriction_id', '=', restriction_id), ('restriction_id', '=', restriction_id),
('applied_on', '=', '0_virtual_room'), ('applied_on', '=', '0_room_type'),
('wpushed', '=', True), ('wpushed', '=', True),
('date_start', '>=', now_utc_str), ('date_start', '>=', now_utc_str),
]) ])

View File

@@ -21,7 +21,7 @@
# #
############################################################################## ##############################################################################
from . import test_wubook from . import test_wubook
from . import test_virtual_room_availability_model from . import test_room_type_availability_model
from . import test_wubook_issue_model from . import test_wubook_issue_model
from . import test_reservation_restriction_item_model from . import test_reservation_restriction_item_model
from . import test_reservation_restriction_model from . import test_reservation_restriction_model
@@ -31,5 +31,5 @@ from . import test_wubook_channel_info_model
from . import test_product_pricelist_model from . import test_product_pricelist_model
from . import test_hotel_calendar_management_model from . import test_hotel_calendar_management_model
from . import test_hotel_folio_model from . import test_hotel_folio_model
from . import test_hotel_virtual_room_model from . import test_hotel_room_type_model
from . import test_hotel_reservation_model from . import test_hotel_reservation_model

View File

@@ -34,7 +34,7 @@ class TestVirtualRoomAvailability(TestHotelWubook):
day_utc_dt = now_utc_dt + timedelta(days=1) day_utc_dt = now_utc_dt + timedelta(days=1)
vroom_avail_obj = self.env['hotel.room.type.availability'] vroom_avail_obj = self.env['hotel.room.type.availability']
avail = vroom_avail_obj.search([ avail = vroom_avail_obj.search([
('virtual_room_id', '=', self.hotel_vroom_budget.id), ('room_type_id', '=', self.hotel_vroom_budget.id),
('date', '=', now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)) ('date', '=', now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT))
], limit=1) ], limit=1)
avail.write({ avail.write({

View File

@@ -589,7 +589,7 @@ class TestWubook(TestHotelWubook):
for vroom in vrooms: for vroom in vrooms:
items = vroom_restr_item_obj.search([ items = vroom_restr_item_obj.search([
('virtual_room_id', '=', vroom.id), ('room_type_id', '=', vroom.id),
('date_start', ('date_start',
'>=', checkin_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)), '>=', checkin_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)),
('date_end', ('date_end',

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<record id="view_channel_hotel_virtual_room_form" model="ir.ui.view"> <record id="view_channel_hotel_room_type_form" model="ir.ui.view">
<field name="name">channel.hotel.virtual.room.form</field> <field name="name">channel.hotel.room.type.form</field>
<field name="model">channel.hotel.virtual.room</field> <field name="model">channel.hotel.room.type</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Hotel Channel Virtual Room"> <form string="Hotel Channel Virtual Room">
<group> <group>
@@ -15,9 +15,9 @@
</field> </field>
</record> </record>
<record id="view_channel_hotel_virtual_room_tree" model="ir.ui.view"> <record id="view_channel_hotel_room_type_tree" model="ir.ui.view">
<field name="name">channel.hotel.virtual.room.tree</field> <field name="name">channel.hotel.room.type.tree</field>
<field name="model">channel.hotel.virtual.room</field> <field name="model">channel.hotel.room.type</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Hotel Channel Virtual Room"> <tree string="Hotel Channel Virtual Room">
<field name="backend_id"/> <field name="backend_id"/>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<record id="view_channel_hotel_virtual_room_availability_form" model="ir.ui.view"> <record id="view_channel_hotel_room_type_availability_form" model="ir.ui.view">
<field name="name">channel.hotel.room.type.availability.form</field> <field name="name">channel.hotel.room.type.availability.form</field>
<field name="model">channel.hotel.room.type.availability</field> <field name="model">channel.hotel.room.type.availability</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
@@ -14,7 +14,7 @@
</field> </field>
</record> </record>
<record id="view_channel_hotel_virtual_room_availability_tree" model="ir.ui.view"> <record id="view_channel_hotel_room_type_availability_tree" model="ir.ui.view">
<field name="name">channel.hotel.room.type.availability.tree</field> <field name="name">channel.hotel.room.type.availability.tree</field>
<field name="model">channel.hotel.virtual.availability.room</field> <field name="model">channel.hotel.virtual.availability.room</field>
<field name="arch" type="xml"> <field name="arch" type="xml">

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<record id="view_channel_hotel_virtual_room_restriction_form" model="ir.ui.view"> <record id="view_channel_hotel_room_type_restriction_form" model="ir.ui.view">
<field name="name">channel.hotel.room.type.restriction.form</field> <field name="name">channel.hotel.room.type.restriction.form</field>
<field name="model">channel.hotel.room.type.restriction</field> <field name="model">channel.hotel.room.type.restriction</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
@@ -14,7 +14,7 @@
</field> </field>
</record> </record>
<record id="view_channel_hotel_virtual_room_restriction_tree" model="ir.ui.view"> <record id="view_channel_hotel_room_type_restriction_tree" model="ir.ui.view">
<field name="name">channel.hotel.room.type.restriction.tree</field> <field name="name">channel.hotel.room.type.restriction.tree</field>
<field name="model">channel.hotel.virtual.restriction.room</field> <field name="model">channel.hotel.virtual.restriction.room</field>
<field name="arch" type="xml"> <field name="arch" type="xml">

View File

@@ -14,7 +14,7 @@
</field> </field>
</record> </record>
<record id="view_channel_hotel_virtual_room_restriction_tree" model="ir.ui.view"> <record id="view_channel_hotel_room_type_restriction_tree" model="ir.ui.view">
<field name="name">channel.hotel.product.pricelist.tree</field> <field name="name">channel.hotel.product.pricelist.tree</field>
<field name="model">channel.hotel.product.pricelist.room</field> <field name="model">channel.hotel.product.pricelist.room</field>
<field name="arch" type="xml"> <field name="arch" type="xml">

View File

@@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<odoo> <odoo>
<record id="virtual_room_view_form" model="ir.ui.view"> <record id="room_type_view_form" model="ir.ui.view">
<field name="model">hotel.room.type</field> <field name="model">hotel.room.type</field>
<field name="inherit_id" ref="hotel.view_hotel_room_type_form" /> <field name="inherit_id" ref="hotel.view_hotel_room_type_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">

View File

@@ -2,9 +2,9 @@
<odoo> <odoo>
<!-- FORM availability --> <!-- FORM availability -->
<record id="virtual_room_availability_view_form" model="ir.ui.view"> <record id="room_type_availability_view_form" model="ir.ui.view">
<field name="model">hotel.room.type.availability</field> <field name="model">hotel.room.type.availability</field>
<field name="inherit_id" ref="hotel.virtual_room_availability_view_form" /> <field name="inherit_id" ref="hotel.room_type_availability_view_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//sheet" position="inside"> <xpath expr="//sheet" position="inside">
<notebook> <notebook>
@@ -23,9 +23,9 @@
</record> </record>
<!-- TREE restriction --> <!-- TREE restriction -->
<record id="virtual_room_availability_view_tree" model="ir.ui.view"> <record id="room_type_availability_view_tree" model="ir.ui.view">
<field name="model">hotel.room.type.availability</field> <field name="model">hotel.room.type.availability</field>
<field name="inherit_id" ref="hotel.virtual_room_availability_view_tree" /> <field name="inherit_id" ref="hotel.room_type_availability_view_tree" />
<field name="type">tree</field> <field name="type">tree</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<!-- <xpath expr="//field[@name='avail']" position="after"> <!-- <xpath expr="//field[@name='avail']" position="after">