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"
|
_description = "Board Services"
|
||||||
|
|
||||||
name = fields.Char('Board Name', size=64, required=True, index=True)
|
name = fields.Char('Board Name', size=64, required=True, index=True)
|
||||||
service_ids = fields.Many2many(comodel_name='product.template',
|
service_ids = fields.Many2many(comodel_name='product.product',
|
||||||
relation='hotel_board_services_room',
|
relation='hotel_board_services_reservation',
|
||||||
column1='board_id',
|
column1='board_id',
|
||||||
column2='service_id')
|
column2='service_id')
|
||||||
sequence = fields.Integer('Sequence')
|
sequence = fields.Integer('Sequence')
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ class HotelReservation(models.Model):
|
|||||||
def open_folio(self):
|
def open_folio(self):
|
||||||
action = self.env.ref('hotel.open_hotel_folio1_form_tree_all').read()[0]
|
action = self.env.ref('hotel.open_hotel_folio1_form_tree_all').read()[0]
|
||||||
if self.folio_id:
|
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
|
action['res_id'] = self.folio_id.id
|
||||||
else:
|
else:
|
||||||
action = {'type': 'ir.actions.act_window_close'}
|
action = {'type': 'ir.actions.act_window_close'}
|
||||||
@@ -417,7 +417,7 @@ class HotelReservation(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def open_reservation_form(self):
|
def open_reservation_form(self):
|
||||||
action = self.env.ref('hotel.open_hotel_reservation_form_tree_all').read()[0]
|
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
|
action['res_id'] = self.id
|
||||||
return action
|
return action
|
||||||
|
|
||||||
@@ -564,6 +564,25 @@ class HotelReservation(models.Model):
|
|||||||
]
|
]
|
||||||
return {'domain': {'room_id': domain_rooms}}
|
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 ----------------------------------------------
|
COMPUTE RESERVE COLOR ----------------------------------------------
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Copyright 2017 Alexandre Díaz
|
# Copyright 2017 Alexandre Díaz
|
||||||
# Copyright 2017 Dario Lodeiros
|
# Copyright 2017 Dario Lodeiros
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# 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 odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
@@ -10,6 +10,28 @@ class HotelService(models.Model):
|
|||||||
_name = 'hotel.service'
|
_name = 'hotel.service'
|
||||||
_description = 'Hotel Services and its charges'
|
_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
|
@api.model
|
||||||
def _default_ser_room_line(self):
|
def _default_ser_room_line(self):
|
||||||
if self.env.context.get('room_lines'):
|
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')
|
service_line_ids = fields.One2many('hotel.service.line', 'service_id')
|
||||||
product_qty = fields.Integer('Quantity')
|
product_qty = fields.Integer('Quantity')
|
||||||
days_qty = fields.Integer(compute="_compute_days_qty", store=True)
|
days_qty = fields.Integer(compute="_compute_days_qty", store=True)
|
||||||
|
is_board_service = fields.Boolean()
|
||||||
pricelist_id = fields.Many2one(related='folio_id.pricelist_id')
|
pricelist_id = fields.Many2one(related='folio_id.pricelist_id')
|
||||||
channel_type = fields.Selection([
|
channel_type = fields.Selection([
|
||||||
('door', 'Door'),
|
('door', 'Door'),
|
||||||
@@ -53,7 +76,7 @@ class HotelService(models.Model):
|
|||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
if self.compute_lines_out_vals(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'])
|
product = self.env['product.product'].browse(vals['product_id'])
|
||||||
params = {
|
params = {
|
||||||
'per_person': product.per_person,
|
'per_person': product.per_person,
|
||||||
@@ -61,7 +84,7 @@ class HotelService(models.Model):
|
|||||||
}
|
}
|
||||||
vals.update(self.prepare_service_lines(
|
vals.update(self.prepare_service_lines(
|
||||||
reservation.checkin,
|
reservation.checkin,
|
||||||
reservation.days,
|
reservation.nights,
|
||||||
params
|
params
|
||||||
))
|
))
|
||||||
record = super(HotelService, self).create(vals)
|
record = super(HotelService, self).create(vals)
|
||||||
@@ -80,15 +103,15 @@ class HotelService(models.Model):
|
|||||||
else:
|
else:
|
||||||
for record in self:
|
for record in self:
|
||||||
reservations = self.env['hotel.reservation']
|
reservations = self.env['hotel.reservation']
|
||||||
reservation = reservations.browse(vals['reservation_id']) \
|
reservation = reservations.browse(vals['ser_room_line']) \
|
||||||
if 'reservation_id' in vals else record.reservation_id
|
if 'ser_room_line' in vals else record.ser_room_line
|
||||||
params = {
|
params = {
|
||||||
'per_person': product.per_person,
|
'per_person': product.per_person,
|
||||||
'persons': reservation.adults
|
'persons': reservation.adults
|
||||||
}
|
}
|
||||||
record.update(record.prepare_service_lines(
|
record.update(record.prepare_service_lines(
|
||||||
reservation.checkin,
|
reservation.checkin,
|
||||||
reservation.days,
|
reservation.nights,
|
||||||
params
|
params
|
||||||
))
|
))
|
||||||
res = super(HotelService, self).write(vals)
|
res = super(HotelService, self).write(vals)
|
||||||
|
|||||||
@@ -245,6 +245,7 @@
|
|||||||
<tree string="Services">
|
<tree string="Services">
|
||||||
<!-- <field name="sequence" widget="handle"/> -->
|
<!-- <field name="sequence" widget="handle"/> -->
|
||||||
<field name="per_day" />
|
<field name="per_day" />
|
||||||
|
<field name="is_board_service" />
|
||||||
<field name="folio_id" invisible="1"/>
|
<field name="folio_id" invisible="1"/>
|
||||||
<field name="product_id"
|
<field name="product_id"
|
||||||
domain="[('sale_ok', '=', True)]"
|
domain="[('sale_ok', '=', True)]"
|
||||||
@@ -253,7 +254,12 @@
|
|||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="product_qty" attrs="{'readonly': [('per_day','=',True)]}" force_save="1"/>
|
<field name="product_qty" attrs="{'readonly': [('per_day','=',True)]}" force_save="1"/>
|
||||||
<field name="days_qty" />
|
<field name="days_qty" />
|
||||||
<field name="service_line_ids" />
|
<field name="service_line_ids" invisible="1">
|
||||||
|
<tree string="Days" >
|
||||||
|
<field name="date" />
|
||||||
|
<field name="day_qty" />
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
</tree>
|
</tree>
|
||||||
<form string="Services">
|
<form string="Services">
|
||||||
<!-- <field name="sequence" widget="handle"/> -->
|
<!-- <field name="sequence" widget="handle"/> -->
|
||||||
|
|||||||
Reference in New Issue
Block a user