mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Extra bed Logic and demo data
This commit is contained in:
@@ -152,6 +152,7 @@
|
||||
<field name="room_type_id" ref="hotel_room_type_2"/>
|
||||
<field name="floor_id" ref="hotel_floor_2"/>
|
||||
<field name="capacity">2</field>
|
||||
<field name="extra_beds_allowed">1</field>
|
||||
</record>
|
||||
<record id="hotel_room_5" model="hotel.room">
|
||||
<field name="name">Double-202</field>
|
||||
@@ -188,9 +189,10 @@
|
||||
<field name="list_price">15.0</field>
|
||||
<field name="type">service</field>
|
||||
<field name="purchase_ok">False</field>
|
||||
<field name="per_day">False</field>
|
||||
<field name="per_person">True</field>
|
||||
<field name="per_day">True</field>
|
||||
<field name="per_person">False</field>
|
||||
<field name="daily_limit">1</field>
|
||||
<field name="is_extra_bed">True</field>
|
||||
</record>
|
||||
|
||||
<record id="hotel_service_3" model="product.product">
|
||||
|
||||
@@ -353,8 +353,8 @@ class HotelReservation(models.Model):
|
||||
service.update(service.prepare_service_lines(
|
||||
dfrom=checkin,
|
||||
days=days_diff,
|
||||
per_person=product.per_person,
|
||||
persons=reservation.adults,
|
||||
per_person=service.product_id.per_person,
|
||||
persons=service.ser_room_line.adults,
|
||||
old_line_days=service.service_line_ids
|
||||
))
|
||||
if ('checkin' in vals and record.checkin != vals['checkin']) or \
|
||||
@@ -485,7 +485,9 @@ class HotelReservation(models.Model):
|
||||
@api.constrains('adults')
|
||||
def _check_adults(self):
|
||||
for record in self:
|
||||
if record.adults > record.room_id.capacity:
|
||||
extra_bed = record.service_ids.filtered(
|
||||
lambda r: r.product_id.is_extra_bed == True)
|
||||
if record.adults > record.room_id.get_capacity(len(extra_bed)):
|
||||
raise ValidationError(
|
||||
_("Reservation persons can't be higher than room capacity"))
|
||||
if record.adults == 0:
|
||||
@@ -499,7 +501,9 @@ class HotelReservation(models.Model):
|
||||
def onchange_room_id(self):
|
||||
if self.room_id:
|
||||
write_vals = {}
|
||||
if self.room_id.capacity < self.adults:
|
||||
extra_bed = self.service_ids.filtered(
|
||||
lambda r: r.product_id.is_extra_bed == True)
|
||||
if self.room_id.get_capacity(len(extra_bed)) < self.adults:
|
||||
raise UserError(
|
||||
_('%s people do not fit in this room! ;)') % (self.adults))
|
||||
if self.adults == 0:
|
||||
|
||||
@@ -32,8 +32,15 @@ class HotelRoom(models.Model):
|
||||
help="A description of the Product that you want to communicate to "
|
||||
" your customers. This description will be copied to every Sales "
|
||||
" Order, Delivery Order and Customer Invoice/Credit Note")
|
||||
extra_beds_allowed = fields.Integer('Extra beds allowed',
|
||||
default='0',
|
||||
required=True)
|
||||
|
||||
@api.constrains('capacity')
|
||||
def _check_capacity(self):
|
||||
if self.capacity < 1:
|
||||
raise ValidationError(_("Room capacity can't be less than one"))
|
||||
|
||||
@api.multi
|
||||
def get_capacity(self, extra_bed=0):
|
||||
return self.capacity + extra_bed
|
||||
|
||||
@@ -145,6 +145,9 @@ class HotelService(models.Model):
|
||||
per_person=product.per_person,
|
||||
persons=reservation.adults,
|
||||
old_line_days=self.service_line_ids))
|
||||
if record.product_id.daily_limit > 0:
|
||||
for day in record.service_line_ids:
|
||||
day.no_free_resources()
|
||||
|
||||
@api.model
|
||||
def prepare_service_lines(self, **kwargs):
|
||||
|
||||
@@ -20,12 +20,15 @@ class HotelServiceLine(models.Model):
|
||||
for record in self:
|
||||
limit = record.product_id.daily_limit
|
||||
if limit > 0:
|
||||
out_qty = sum(self.env['hotel.service.line'].search([(
|
||||
'product_id', '=', record.product_id,
|
||||
'date', '=', record.date)]).mapped('day_qty'))
|
||||
out_qty = sum(self.env['hotel.service.line'].search([
|
||||
('product_id', '=', record.product_id.id),
|
||||
('date', '=', record.date),
|
||||
('service_id', '!=', record.service_id.id)
|
||||
]).mapped('day_qty'))
|
||||
if limit < out_qty + record.day_qty:
|
||||
raise ValidationError(
|
||||
_("Limit exceeded for %s")% record.date)
|
||||
_("%s limit exceeded for %s")% (record.service_id.product_id.name,
|
||||
record.date))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from openerp import models, fields
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
is_hotel_service = fields.Boolean('Is a Hotel Service', default=False)
|
||||
per_day = fields.Boolean('Unit increment per day')
|
||||
per_person = fields.Boolean('Unit increment per person')
|
||||
daily_limit = fields.Integer('Daily limit')
|
||||
is_extra_bed = fields.Boolean('Is extra bed', default=False)
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<field name="room_type_id" string="Room Type" />
|
||||
<field name="capacity" />
|
||||
<field name="shared_room" help="It allows several reservations on the same room simultaneously based on the capacity of people"/>
|
||||
<field name="extra_beds_allowed" />
|
||||
<!-- <field name="uom_id" invisible="1" /> -->
|
||||
</group>
|
||||
<group>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<page string="Hotel Service">
|
||||
<group colspan="4">
|
||||
<group>
|
||||
<field name="is_hotel_service" />
|
||||
<field name="is_extra_bed" />
|
||||
<field name="daily_limit" />
|
||||
</group>
|
||||
<group>
|
||||
|
||||
Reference in New Issue
Block a user