mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Board service in reservation
This commit is contained in:
@@ -8,8 +8,8 @@ class HotelBoardService(models.Model):
|
||||
_description = "Board Services"
|
||||
|
||||
name = fields.Char('Board Name', size=64, required=True, index=True)
|
||||
service_ids = fields.Many2many(comodel_name='product.template',
|
||||
relation='hotel_board_services_room',
|
||||
service_ids = fields.Many2many(comodel_name='product.product',
|
||||
relation='hotel_board_services_reservation',
|
||||
column1='board_id',
|
||||
column2='service_id')
|
||||
sequence = fields.Integer('Sequence')
|
||||
|
||||
@@ -408,7 +408,7 @@ class HotelReservation(models.Model):
|
||||
def open_folio(self):
|
||||
action = self.env.ref('hotel.open_hotel_folio1_form_tree_all').read()[0]
|
||||
if self.folio_id:
|
||||
action['views'] = [(self.env.ref('hotel.view_hotel_folio1_form').id, 'form')]
|
||||
action['views'] = [(self.env.ref('hotel.hotel_folio_view_form').id, 'form')]
|
||||
action['res_id'] = self.folio_id.id
|
||||
else:
|
||||
action = {'type': 'ir.actions.act_window_close'}
|
||||
@@ -417,7 +417,7 @@ class HotelReservation(models.Model):
|
||||
@api.multi
|
||||
def open_reservation_form(self):
|
||||
action = self.env.ref('hotel.open_hotel_reservation_form_tree_all').read()[0]
|
||||
action['views'] = [(self.env.ref('hotel.view_hotel_reservation_form').id, 'form')]
|
||||
action['views'] = [(self.env.ref('hotel.hotel_reservation_view_form').id, 'form')]
|
||||
action['res_id'] = self.id
|
||||
return action
|
||||
|
||||
@@ -564,6 +564,25 @@ class HotelReservation(models.Model):
|
||||
]
|
||||
return {'domain': {'room_id': domain_rooms}}
|
||||
|
||||
@api.onchange('board_service_id')
|
||||
def onchange_board_service(self):
|
||||
if self.board_service_id:
|
||||
self.service_line_ids.filtered(lambda r: r.is_board_service == True).unlink()
|
||||
board_services = []
|
||||
for product in self.board_service_id.service_ids:
|
||||
board_services.append((0, False, {
|
||||
'product_id': product.id,
|
||||
'is_board_service': True,
|
||||
}))
|
||||
# NEED REVIEW: Why I need add manually the old IDs if board service is (0,0,(-)) ¿?¿?¿
|
||||
self.update({'service_line_ids': [(6, 0, self.service_line_ids.ids)] + board_services})
|
||||
update_services = self.service_line_ids.filtered(
|
||||
lambda r: r.is_board_service == True
|
||||
)
|
||||
for service in update_services:
|
||||
service.onchange_product_calc_qty()
|
||||
|
||||
|
||||
"""
|
||||
COMPUTE RESERVE COLOR ----------------------------------------------
|
||||
"""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Copyright 2017 Alexandre Díaz
|
||||
# Copyright 2017 Dario Lodeiros
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields, api
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from datetime import timedelta
|
||||
from odoo.exceptions import ValidationError
|
||||
@@ -10,6 +10,28 @@ class HotelService(models.Model):
|
||||
_name = 'hotel.service'
|
||||
_description = 'Hotel Services and its charges'
|
||||
|
||||
@api.model
|
||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
||||
if args is None:
|
||||
args = []
|
||||
if not(name == '' and operator == 'ilike'):
|
||||
args += [
|
||||
'|',
|
||||
('ser_room_line.name', operator, name),
|
||||
('name', operator, name)
|
||||
]
|
||||
return super(HotelService, self).name_search(
|
||||
name='', args=args, operator='ilike', limit=limit)
|
||||
|
||||
@api.multi
|
||||
def name_get(self):
|
||||
result = []
|
||||
for res in self:
|
||||
name = u'%s (%s)' % (res.name, res.ser_room_line.name)
|
||||
result.append((res.id, name))
|
||||
return result
|
||||
|
||||
|
||||
@api.model
|
||||
def _default_ser_room_line(self):
|
||||
if self.env.context.get('room_lines'):
|
||||
@@ -27,6 +49,7 @@ class HotelService(models.Model):
|
||||
service_line_ids = fields.One2many('hotel.service.line', 'service_id')
|
||||
product_qty = fields.Integer('Quantity')
|
||||
days_qty = fields.Integer(compute="_compute_days_qty", store=True)
|
||||
is_board_service = fields.Boolean()
|
||||
pricelist_id = fields.Many2one(related='folio_id.pricelist_id')
|
||||
channel_type = fields.Selection([
|
||||
('door', 'Door'),
|
||||
@@ -53,7 +76,7 @@ class HotelService(models.Model):
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if self.compute_lines_out_vals(vals):
|
||||
reservation = self.env['hotel.reservation'].browse(vals['reservation_id'])
|
||||
reservation = self.env['hotel.reservation'].browse(vals['ser_room_line'])
|
||||
product = self.env['product.product'].browse(vals['product_id'])
|
||||
params = {
|
||||
'per_person': product.per_person,
|
||||
@@ -61,7 +84,7 @@ class HotelService(models.Model):
|
||||
}
|
||||
vals.update(self.prepare_service_lines(
|
||||
reservation.checkin,
|
||||
reservation.days,
|
||||
reservation.nights,
|
||||
params
|
||||
))
|
||||
record = super(HotelService, self).create(vals)
|
||||
@@ -80,15 +103,15 @@ class HotelService(models.Model):
|
||||
else:
|
||||
for record in self:
|
||||
reservations = self.env['hotel.reservation']
|
||||
reservation = reservations.browse(vals['reservation_id']) \
|
||||
if 'reservation_id' in vals else record.reservation_id
|
||||
reservation = reservations.browse(vals['ser_room_line']) \
|
||||
if 'ser_room_line' in vals else record.ser_room_line
|
||||
params = {
|
||||
'per_person': product.per_person,
|
||||
'persons': reservation.adults
|
||||
}
|
||||
record.update(record.prepare_service_lines(
|
||||
reservation.checkin,
|
||||
reservation.days,
|
||||
reservation.nights,
|
||||
params
|
||||
))
|
||||
res = super(HotelService, self).write(vals)
|
||||
|
||||
Reference in New Issue
Block a user