[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

@@ -19,7 +19,7 @@ from . import inherit_account_invoice
# from . import inherit_product_category
from . import inherit_product_product
from . import inherit_res_company
# from . import virtual_room
# from . import room_type
from . import inherit_account_payment
from . import hotel_room_type_restriction
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):
_name = "currency.exchange"
_description = "currency"

View File

@@ -21,6 +21,10 @@ from odoo.addons import decimal_precision as dp
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')
def _get_invoice_qty(self):
@@ -41,12 +45,6 @@ class HotelFolio(models.Model):
def _amount_all(self):
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,
default=lambda self: _('New'))
partner_id = fields.Many2one('res.partner',

View File

@@ -16,6 +16,10 @@ _logger = logging.getLogger(__name__)
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):
folio = False
@@ -110,11 +114,6 @@ class HotelReservation(models.Model):
fields.Date.from_string(res.checkout) - fields.Date.from_string(res.checkin)
).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)
room_id = fields.Many2one('hotel.room', string='Room')
@@ -312,9 +311,12 @@ class HotelReservation(models.Model):
})
for record in self:
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 = (
fields.Date.from_string(record.checkout) - \
fields.Date.from_string(record.checkin)
fields.Date.from_string(checkout) - \
fields.Date.from_string(checkin)
).days
record.update(record.prepare_reservation_lines(
vals['checkin'],
@@ -390,7 +392,7 @@ class HotelReservation(models.Model):
'overbooking': self.overbooking,
'price_unit': self.price_unit,
'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,
}
@@ -419,7 +421,7 @@ class HotelReservation(models.Model):
#Si el registro no existe, modificar room_type aunque ya esté establecido
if not self.room_type_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')
def onchange_partner_id(self):

View File

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

View File

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

View File

@@ -10,8 +10,8 @@ class HotelRoomType(models.Model):
"""
_name = "hotel.room.type"
_description = "Room Type"
_inherits = {'product.product': 'product_id'}
# Relationship between models
product_id = fields.Many2one('product.product', 'Product Room Type',
required=True, delegate=True,
@@ -59,7 +59,7 @@ class HotelRoomType(models.Model):
@api.model
# 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=[]):
"""
Check the avalability for an specific type of room

View File

@@ -10,7 +10,7 @@ class HotelRoomTypeAvailability(models.Model):
_inherit = 'mail.thread'
_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',
# ondelete='cascade')
room_type_id = fields.Many2one('hotel.room.type', 'Room Type',
@@ -34,7 +34,7 @@ class HotelRoomTypeAvailability(models.Model):
self.avail = 0
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,
room_type_id=self.room_type_id.id))
@@ -44,7 +44,7 @@ class HotelRoomTypeAvailability(models.Model):
self.avail = max_avail
@api.constrains('date', 'room_type_id')
def _check_date_virtual_room_id(self):
def _check_date_room_type_id(self):
count = self.search_count([
('date', '=', self.date),
('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 Plan', ondelete='cascade',
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')
room_type_id = fields.Many2one('hotel.room.type', 'Room Type',
required=True, ondelete='cascade')
@@ -21,8 +21,8 @@ class HotelRoomTypeRestrictionItem(models.Model):
date_end = fields.Date("To")
applied_on = fields.Selection([
('1_global', 'Global'),
# ('0_virtual_room', 'Virtual Room')], string="Apply On", required=True,
# default='0_virtual_room',
# ('0_room_type', 'Virtual Room')], string="Apply On", required=True,
# default='0_room_type',
('0_room_type', 'Room Type')], string="Apply On", required=True,
default='0_room_type',
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__)
class HotelService(models.Model):
_name = 'hotel.service'
_description = 'Hotel Services and its charges'
@api.model
def _service_checkin(self):
if 'checkin' in self._context:
@@ -30,9 +32,6 @@ class HotelService(models.Model):
], limit=1)
return False
_name = 'hotel.service'
_description = 'Hotel Services and its charges'
name = fields.Char('Service description')
# services in the hotel are products
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,
'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,
#~ prod.taxes_id,

View File

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