mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
Merge pull request #79 from hootel/pr_onboard_service_line
Pr onboard service line
This commit is contained in:
@@ -50,6 +50,7 @@
|
|||||||
'views/hotel_board_service_views.xml',
|
'views/hotel_board_service_views.xml',
|
||||||
'views/hotel_checkin_partner_views.xml',
|
'views/hotel_checkin_partner_views.xml',
|
||||||
'views/hotel_room_type_availability_views.xml',
|
'views/hotel_room_type_availability_views.xml',
|
||||||
|
'views/hotel_board_service_room_type_views.xml',
|
||||||
'data/cron_jobs.xml',
|
'data/cron_jobs.xml',
|
||||||
'data/records.xml',
|
'data/records.xml',
|
||||||
'data/email_template_cancel.xml',
|
'data/email_template_cancel.xml',
|
||||||
|
|||||||
@@ -235,24 +235,90 @@
|
|||||||
|
|
||||||
<record id="hotel_board_service_0" model="hotel.board.service">
|
<record id="hotel_board_service_0" model="hotel.board.service">
|
||||||
<field name="name">BreakFast</field>
|
<field name="name">BreakFast</field>
|
||||||
<field name="service_ids"
|
<field name="board_service_line_ids"
|
||||||
eval="[(4, ref('hotel_service_0'))]"/>
|
eval="[(5, 0), (0, 0, {
|
||||||
<field name="sequence">0</field>
|
'product_id': ref('hotel_service_0'),
|
||||||
|
'amount': 3})]"/>
|
||||||
|
<field name="price_type">fixed</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="hotel_board_service_1" model="hotel.board.service">
|
<record id="hotel_board_service_1" model="hotel.board.service">
|
||||||
<field name="name">Half Board</field>
|
<field name="name">Half Board</field>
|
||||||
<field name="service_ids"
|
<field name="board_service_line_ids"
|
||||||
eval="[(4, ref('hotel_service_0')), (4, ref('hotel_service_4'))]"/>
|
eval="[(5, 0), (0, 0, {
|
||||||
<field name="sequence">10</field>
|
'product_id': ref('hotel_service_0'),
|
||||||
|
'amount': 3}),
|
||||||
|
(0, 0, {'product_id': ref('hotel_service_4'),
|
||||||
|
'amount': 8})
|
||||||
|
]"/>
|
||||||
|
<field name="price_type">fixed</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="hotel_board_service_2" model="hotel.board.service">
|
<record id="hotel_board_service_2" model="hotel.board.service">
|
||||||
<field name="name">FullBoard</field>
|
<field name="name">FullBoard</field>
|
||||||
<field name="service_ids"
|
<field name="board_service_line_ids"
|
||||||
eval="[(4, ref('hotel_service_0')), (4, ref('hotel_service_4')),
|
eval="[(5, 0), (0, 0, {
|
||||||
(4, ref('hotel_service_5'))]"/>
|
'product_id': ref('hotel_service_0'),
|
||||||
<field name="sequence">10</field>
|
'amount': 3}),
|
||||||
|
(0, 0, {'product_id': ref('hotel_service_4'),
|
||||||
|
'amount': 8}),
|
||||||
|
(0, 0, {'product_id': ref('hotel_service_5'),
|
||||||
|
'amount': 8})
|
||||||
|
]"/>
|
||||||
|
<field name="price_type">fixed</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- hotel.board.service.room.type -->
|
||||||
|
|
||||||
|
<!--Room 0 Economic-->
|
||||||
|
|
||||||
|
<record id="hotel_board_service_room_0"
|
||||||
|
model="hotel.board.service.room.type">
|
||||||
|
<field name="hotel_board_service_id"
|
||||||
|
ref="hotel_board_service_0"/>
|
||||||
|
<field name="hotel_room_type_id"
|
||||||
|
ref="hotel_room_type_0"/>
|
||||||
|
<field name="price_type">fixed</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="hotel_board_service_room_1"
|
||||||
|
model="hotel.board.service.room.type">
|
||||||
|
<field name="hotel_board_service_id"
|
||||||
|
ref="hotel_board_service_1"/>
|
||||||
|
<field name="hotel_room_type_id"
|
||||||
|
ref="hotel_room_type_0"/>
|
||||||
|
<field name="price_type">fixed</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="hotel_board_service_room_2"
|
||||||
|
model="hotel.board.service.room.type">
|
||||||
|
<field name="hotel_board_service_id"
|
||||||
|
ref="hotel_board_service_1"/>
|
||||||
|
<field name="hotel_room_type_id"
|
||||||
|
ref="hotel_room_type_0"/>
|
||||||
|
<field name="pricelist_id"
|
||||||
|
ref="product.list0"/>
|
||||||
|
<field name="price_type">fixed</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!--Room 3 Triple-->
|
||||||
|
|
||||||
|
<record id="hotel_board_service_room_3"
|
||||||
|
model="hotel.board.service.room.type">
|
||||||
|
<field name="hotel_board_service_id"
|
||||||
|
ref="hotel_board_service_0"/>
|
||||||
|
<field name="hotel_room_type_id"
|
||||||
|
ref="hotel_room_type_3"/>
|
||||||
|
<field name="price_type">fixed</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="hotel_board_service_room_4"
|
||||||
|
model="hotel.board.service.room.type">
|
||||||
|
<field name="hotel_board_service_id"
|
||||||
|
ref="hotel_board_service_2"/>
|
||||||
|
<field name="hotel_room_type_id"
|
||||||
|
ref="hotel_room_type_3"/>
|
||||||
|
<field name="price_type">fixed</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- room.closure.reason -->
|
<!-- room.closure.reason -->
|
||||||
@@ -280,7 +346,7 @@
|
|||||||
'checkout': (DateTime.today() + timedelta(days=2)).strftime('%Y-%m-%d'),
|
'checkout': (DateTime.today() + timedelta(days=2)).strftime('%Y-%m-%d'),
|
||||||
'adults': 2,
|
'adults': 2,
|
||||||
'state': 'confirm',
|
'state': 'confirm',
|
||||||
'board_service_id': ref('hotel_board_service_1'),
|
'board_service_room_id': ref('hotel_board_service_room_1'),
|
||||||
})]"/>
|
})]"/>
|
||||||
</record>
|
</record>
|
||||||
<!-- reservation of 1 triple room for 3 people on behalf on the company -->
|
<!-- reservation of 1 triple room for 3 people on behalf on the company -->
|
||||||
@@ -292,7 +358,7 @@
|
|||||||
'checkin': (DateTime.today() + timedelta(days=2)).strftime('%Y-%m-%d'),
|
'checkin': (DateTime.today() + timedelta(days=2)).strftime('%Y-%m-%d'),
|
||||||
'checkout': (DateTime.today() + timedelta(days=4)).strftime('%Y-%m-%d'),
|
'checkout': (DateTime.today() + timedelta(days=4)).strftime('%Y-%m-%d'),
|
||||||
'adults': 3,
|
'adults': 3,
|
||||||
'board_service_id': ref('hotel_board_service_2'),
|
'board_service_room_id': ref('hotel_board_service_room_3'),
|
||||||
})]"/>
|
})]"/>
|
||||||
</record>
|
</record>
|
||||||
<!-- reservation of 3 single rooms for 3 people with 1 cancelled -->
|
<!-- reservation of 3 single rooms for 3 people with 1 cancelled -->
|
||||||
@@ -329,7 +395,6 @@
|
|||||||
'checkout': (DateTime.today() + timedelta(days=4)).strftime('%Y-%m-%d'),
|
'checkout': (DateTime.today() + timedelta(days=4)).strftime('%Y-%m-%d'),
|
||||||
'adults': 1,
|
'adults': 1,
|
||||||
'state': 'confirm',
|
'state': 'confirm',
|
||||||
'board_service_id': ref('hotel_board_service_1'),
|
|
||||||
})]"/>
|
})]"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -29,3 +29,5 @@ from . import hotel_room_type_class
|
|||||||
from . import hotel_room_closure_reason
|
from . import hotel_room_closure_reason
|
||||||
from . import hotel_service_line
|
from . import hotel_service_line
|
||||||
from . import hotel_board_service
|
from . import hotel_board_service
|
||||||
|
from . import hotel_board_service_room_type_line
|
||||||
|
from . import hotel_board_service_line
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# 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
|
from odoo import api, models, fields
|
||||||
|
from odoo.addons import decimal_precision as dp
|
||||||
|
|
||||||
|
|
||||||
class HotelBoardService(models.Model):
|
class HotelBoardService(models.Model):
|
||||||
@@ -8,8 +9,23 @@ 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.product',
|
board_service_line_ids = fields.One2many('hotel.board.service.line',
|
||||||
relation='hotel_board_services_reservation',
|
'hotel_board_service_id')
|
||||||
column1='board_id',
|
price_type = fields.Selection([
|
||||||
column2='service_id')
|
('fixed','Fixed'),
|
||||||
sequence = fields.Integer('Sequence')
|
('percent','Percent')], string='Type', default='fixed', required=True)
|
||||||
|
hotel_board_service_room_type_ids = fields.One2many(
|
||||||
|
'hotel.board.service.room.type', 'hotel_board_service_id')
|
||||||
|
amount = fields.Float('Amount',
|
||||||
|
digits=dp.get_precision('Product Price'),
|
||||||
|
compute='_compute_board_amount',
|
||||||
|
store=True)
|
||||||
|
|
||||||
|
@api.depends('board_service_line_ids.amount')
|
||||||
|
def _compute_board_amount(self):
|
||||||
|
for record in self:
|
||||||
|
total = 0
|
||||||
|
for service in record.board_service_line_ids:
|
||||||
|
total += service.amount
|
||||||
|
record.update({'amount': total})
|
||||||
|
|
||||||
|
|||||||
29
hotel/models/hotel_board_service_line.py
Normal file
29
hotel/models/hotel_board_service_line.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Copyright 2017 Dario Lodeiros
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
from odoo import api, fields, models, _
|
||||||
|
from odoo.addons import decimal_precision as dp
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
|
class HotelBoardServiceLine(models.Model):
|
||||||
|
_name = 'hotel.board.service.line'
|
||||||
|
_description = 'Services on Board Service included'
|
||||||
|
|
||||||
|
def _get_default_price(self):
|
||||||
|
if self.product_id:
|
||||||
|
return self.product_id.list_price
|
||||||
|
|
||||||
|
hotel_board_service_id = fields.Many2one(
|
||||||
|
'hotel.board.service', 'Board Service', ondelete='cascade', required=True)
|
||||||
|
product_id = fields.Many2one(
|
||||||
|
'product.product', 'Product', required=True)
|
||||||
|
amount = fields.Float('Amount',
|
||||||
|
digits=dp.get_precision('Product Price'), default=_get_default_price)
|
||||||
|
|
||||||
|
@api.onchange('product_id')
|
||||||
|
def onchange_product_id(self):
|
||||||
|
if self.product_id:
|
||||||
|
self.update({'amount': self.product_id.list_price})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -12,6 +12,17 @@ class HotelBoardServiceRoomType(models.Model):
|
|||||||
_log_access = False
|
_log_access = False
|
||||||
_description = 'Board Service included in Room'
|
_description = 'Board Service included in Room'
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def name_get(self):
|
||||||
|
result = []
|
||||||
|
for res in self:
|
||||||
|
if res.pricelist_id:
|
||||||
|
name = u'%s (%s)' % (res.hotel_board_service_id.name, res.pricelist_id.name)
|
||||||
|
else:
|
||||||
|
name = u'%s (%s)' % (res.hotel_board_service_id.name, _('Generic'))
|
||||||
|
result.append((res.id, name))
|
||||||
|
return result
|
||||||
|
|
||||||
hotel_board_service_id = fields.Many2one(
|
hotel_board_service_id = fields.Many2one(
|
||||||
'hotel.board.service', 'Board Service', index=True, ondelete='cascade', required=True)
|
'hotel.board.service', 'Board Service', index=True, ondelete='cascade', required=True)
|
||||||
hotel_room_type_id = fields.Many2one(
|
hotel_room_type_id = fields.Many2one(
|
||||||
@@ -21,7 +32,11 @@ class HotelBoardServiceRoomType(models.Model):
|
|||||||
price_type = fields.Selection([
|
price_type = fields.Selection([
|
||||||
('fixed','Fixed'),
|
('fixed','Fixed'),
|
||||||
('percent','Percent')], string='Type', default='fixed', required=True)
|
('percent','Percent')], string='Type', default='fixed', required=True)
|
||||||
amount = fields.Float('Amount', digits=dp.get_precision('Product Price'), default=0.0)
|
amount = fields.Float('Amount',
|
||||||
|
digits=dp.get_precision('Product Price'),
|
||||||
|
compute='_compute_board_amount',
|
||||||
|
store=True)
|
||||||
|
board_service_line_ids = fields.One2many('hotel.board.service.room.type.line', 'hotel_board_service_room_type_id')
|
||||||
|
|
||||||
@api.model_cr
|
@api.model_cr
|
||||||
def init(self):
|
def init(self):
|
||||||
@@ -29,6 +44,52 @@ class HotelBoardServiceRoomType(models.Model):
|
|||||||
if not self._cr.fetchone():
|
if not self._cr.fetchone():
|
||||||
self._cr.execute('CREATE INDEX hotel_board_service_id_hotel_room_type_id_pricelist_id ON hotel_board_service_room_type_rel (hotel_board_service_id, hotel_room_type_id, pricelist_id)')
|
self._cr.execute('CREATE INDEX hotel_board_service_id_hotel_room_type_id_pricelist_id ON hotel_board_service_room_type_rel (hotel_board_service_id, hotel_room_type_id, pricelist_id)')
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def create(self, vals):
|
||||||
|
if 'hotel_board_service_id' in vals:
|
||||||
|
vals.update(
|
||||||
|
self.prepare_board_service_room_lines(vals['hotel_board_service_id'])
|
||||||
|
)
|
||||||
|
return super(HotelBoardServiceRoomType, self).create(vals)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def write(self, vals):
|
||||||
|
if 'hotel_board_service_id' in vals:
|
||||||
|
vals.update(
|
||||||
|
self.prepare_board_service_room_lines(vals['hotel_board_service_id'])
|
||||||
|
)
|
||||||
|
return super(HotelBoardServiceRoomType, self).write(vals)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def open_board_lines_form(self):
|
||||||
|
action = self.env.ref('hotel.action_hotel_board_service_room_type_view').read()[0]
|
||||||
|
action['views'] = [(self.env.ref('hotel.hotel_board_service_room_type_form').id, 'form')]
|
||||||
|
action['res_id'] = self.id
|
||||||
|
action['target'] = 'new'
|
||||||
|
return action
|
||||||
|
|
||||||
|
@api.depends('board_service_line_ids.amount')
|
||||||
|
def _compute_board_amount(self):
|
||||||
|
for record in self:
|
||||||
|
total = 0
|
||||||
|
for service in record.board_service_line_ids:
|
||||||
|
total += service.amount
|
||||||
|
record.update({'amount': total})
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def prepare_board_service_room_lines(self, board_service_id):
|
||||||
|
"""
|
||||||
|
Prepare line to price products config
|
||||||
|
"""
|
||||||
|
cmds=[(5,0,0)]
|
||||||
|
board_service = self.env['hotel.board.service'].browse(board_service_id)
|
||||||
|
for line in board_service.board_service_line_ids:
|
||||||
|
cmds.append((0, False, {
|
||||||
|
'product_id': line.product_id.id,
|
||||||
|
'amount': line.amount
|
||||||
|
}))
|
||||||
|
return {'board_service_line_ids': cmds}
|
||||||
|
|
||||||
@api.constrains('pricelist_id')
|
@api.constrains('pricelist_id')
|
||||||
def constrains_pricelist_id(self):
|
def constrains_pricelist_id(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
|
|||||||
21
hotel/models/hotel_board_service_room_type_line.py
Normal file
21
hotel/models/hotel_board_service_room_type_line.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Copyright 2017 Dario Lodeiros
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
from odoo import api, fields, models, _
|
||||||
|
from odoo.addons import decimal_precision as dp
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
|
class HotelBoardServiceRoomTypeLine(models.Model):
|
||||||
|
_name = 'hotel.board.service.room.type.line'
|
||||||
|
_description = 'Services on Board Service included in Room'
|
||||||
|
|
||||||
|
#TODO def default_amount "amount of service"
|
||||||
|
|
||||||
|
hotel_board_service_room_type_id = fields.Many2one(
|
||||||
|
'hotel.board.service.room.type', 'Board Service Room', ondelete='cascade', required=True)
|
||||||
|
product_id = fields.Many2one(
|
||||||
|
'product.product', 'Product', required=True, readonly=True)
|
||||||
|
amount = fields.Float('Amount', digits=dp.get_precision('Product Price'), default=0.0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from lxml import etree
|
||||||
from odoo.exceptions import UserError, ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
from odoo.tools import (
|
from odoo.tools import (
|
||||||
misc,
|
misc,
|
||||||
@@ -133,7 +134,8 @@ class HotelReservation(models.Model):
|
|||||||
track_visibility='onchange')
|
track_visibility='onchange')
|
||||||
reservation_type = fields.Selection(related='folio_id.reservation_type',
|
reservation_type = fields.Selection(related='folio_id.reservation_type',
|
||||||
default=lambda *a: 'normal')
|
default=lambda *a: 'normal')
|
||||||
board_service_id = fields.Many2one('hotel.board.service', string='Board Service')
|
board_service_room_id = fields.Many2one('hotel.board.service.room.type',
|
||||||
|
string='Board Service')
|
||||||
cancelled_reason = fields.Selection([
|
cancelled_reason = fields.Selection([
|
||||||
('late', 'Late'),
|
('late', 'Late'),
|
||||||
('intime', 'In time'),
|
('intime', 'In time'),
|
||||||
@@ -290,12 +292,12 @@ class HotelReservation(models.Model):
|
|||||||
vals.update({
|
vals.update({
|
||||||
'last_updated_res': fields.Datetime.now(),
|
'last_updated_res': fields.Datetime.now(),
|
||||||
})
|
})
|
||||||
if 'board_service_id' in vals:
|
if 'board_service_room_id' in vals:
|
||||||
board_services = []
|
board_services = []
|
||||||
board = self.env['hotel.board.service'].browse(vals['board_service_id'])
|
board = self.env['hotel.board.service.room.type'].browse(vals['board_service_room_id'])
|
||||||
for product in board.service_ids:
|
for line in board.board_service_line_ids:
|
||||||
board_services.append((0, False, {
|
board_services.append((0, False, {
|
||||||
'product_id': product.id,
|
'product_id': line.product_id.id,
|
||||||
'is_board_service': True,
|
'is_board_service': True,
|
||||||
'folio_id': vals.get('folio_id'),
|
'folio_id': vals.get('folio_id'),
|
||||||
}))
|
}))
|
||||||
@@ -330,10 +332,10 @@ class HotelReservation(models.Model):
|
|||||||
if self.compute_board_services(vals):
|
if self.compute_board_services(vals):
|
||||||
record.service_ids.filtered(lambda r: r.is_board_service == True).unlink()
|
record.service_ids.filtered(lambda r: r.is_board_service == True).unlink()
|
||||||
board_services = []
|
board_services = []
|
||||||
board = self.env['hotel.board.service'].browse(vals['board_service_id'])
|
board = self.env['hotel.board.service.room.type'].browse(vals['board_service_room_id'])
|
||||||
for product in board.service_ids:
|
for line in board.board_service_line_ids:
|
||||||
board_services.append((0, False, {
|
board_services.append((0, False, {
|
||||||
'product_id': product.id,
|
'product_id': line.product_id.id,
|
||||||
'is_board_service': True,
|
'is_board_service': True,
|
||||||
'folio_id': record.folio_id.id or vals.get('folio_id')
|
'folio_id': record.folio_id.id or vals.get('folio_id')
|
||||||
}))
|
}))
|
||||||
@@ -369,10 +371,10 @@ class HotelReservation(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def compute_board_services(self, vals):
|
def compute_board_services(self, vals):
|
||||||
"""
|
"""
|
||||||
We must compute service_ids when we hace a board_service_id without
|
We must compute service_ids when we have a board_service_id without
|
||||||
service_ids associated to reservation
|
service_ids associated to reservation
|
||||||
"""
|
"""
|
||||||
if 'board_service_id' in vals:
|
if 'board_service_room_id' in vals:
|
||||||
if 'service_ids' in vals:
|
if 'service_ids' in vals:
|
||||||
for service in vals['service_ids']:
|
for service in vals['service_ids']:
|
||||||
if 'is_board_service' in service[2] and \
|
if 'is_board_service' in service[2] and \
|
||||||
@@ -402,7 +404,7 @@ class HotelReservation(models.Model):
|
|||||||
""" Deduce missing required fields from the onchange """
|
""" Deduce missing required fields from the onchange """
|
||||||
res = {}
|
res = {}
|
||||||
onchange_fields = ['room_id', 'reservation_type',
|
onchange_fields = ['room_id', 'reservation_type',
|
||||||
'currency_id', 'name', 'board_service_id']
|
'currency_id', 'name', 'board_service_room_id']
|
||||||
if values.get('room_type_id'):
|
if values.get('room_type_id'):
|
||||||
line = self.new(values)
|
line = self.new(values)
|
||||||
if any(f not in values for f in onchange_fields):
|
if any(f not in values for f in onchange_fields):
|
||||||
@@ -610,11 +612,12 @@ class HotelReservation(models.Model):
|
|||||||
]
|
]
|
||||||
return {'domain': {'room_id': domain_rooms}}
|
return {'domain': {'room_id': domain_rooms}}
|
||||||
|
|
||||||
@api.onchange('board_service_id')
|
@api.onchange('board_service_room_id')
|
||||||
def onchange_board_service(self):
|
def onchange_board_service(self):
|
||||||
if self.board_service_id:
|
if self.board_service_room_id:
|
||||||
board_services = []
|
board_services = []
|
||||||
for product in self.board_service_id.service_ids:
|
for line in self.board_service_room_id.board_service_line_ids:
|
||||||
|
product = line.product_id
|
||||||
if product.per_day:
|
if product.per_day:
|
||||||
vals = {
|
vals = {
|
||||||
'product_id': product.id,
|
'product_id': product.id,
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class HotelService(models.Model):
|
|||||||
def _compute_tax_ids(self):
|
def _compute_tax_ids(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
# If company_id is set, always filter taxes by the company
|
# If company_id is set, always filter taxes by the company
|
||||||
folio = self.folio_id or self.env.context.get('default_folio_id')
|
folio = record.folio_id or self.env.context.get('default_folio_id')
|
||||||
record.tax_id = record.product_id.taxes_id.filtered(lambda r: not record.company_id or r.company_id == folio.company_id)
|
record.tax_id = record.product_id.taxes_id.filtered(lambda r: not record.company_id or r.company_id == folio.company_id)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -184,12 +184,12 @@ class HotelService(models.Model):
|
|||||||
if record.per_day and record.ser_room_line:
|
if record.per_day and record.ser_room_line:
|
||||||
product = record.product_id
|
product = record.product_id
|
||||||
reservation = record.ser_room_line
|
reservation = record.ser_room_line
|
||||||
vals.update(self.prepare_service_lines(
|
vals.update(record.prepare_service_lines(
|
||||||
dfrom=reservation.checkin,
|
dfrom=reservation.checkin,
|
||||||
days=reservation.nights,
|
days=reservation.nights,
|
||||||
per_person=product.per_person,
|
per_person=product.per_person,
|
||||||
persons=reservation.adults,
|
persons=reservation.adults,
|
||||||
old_line_days=self.service_line_ids))
|
old_line_days=record.service_line_ids))
|
||||||
if record.product_id.daily_limit > 0:
|
if record.product_id.daily_limit > 0:
|
||||||
for day in record.service_line_ids:
|
for day in record.service_line_ids:
|
||||||
day.no_free_resources()
|
day.no_free_resources()
|
||||||
@@ -202,21 +202,33 @@ class HotelService(models.Model):
|
|||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _compute_price_unit(self):
|
def _compute_price_unit(self):
|
||||||
"""
|
self.ensure_one()
|
||||||
Compute tax and price unit
|
|
||||||
"""
|
|
||||||
folio = self.folio_id or self.env.context.get('default_folio_id')
|
folio = self.folio_id or self.env.context.get('default_folio_id')
|
||||||
product = self.product_id.with_context(
|
reservation = self.ser_room_line or self.env.context.get('ser_room_line')
|
||||||
lang=folio.partner_id.lang,
|
if folio or reservation:
|
||||||
partner=folio.partner_id.id,
|
partner = folio.partner_id if folio else reservation.partner_id
|
||||||
quantity=self.product_qty,
|
pricelist = folio.pricelist_id if folio else reservation.pricelist_id
|
||||||
date=folio.date_order,
|
if reservation and self.is_board_service:
|
||||||
pricelist=folio.pricelist_id.id,
|
board_room_type = reservation.board_service_room_id
|
||||||
uom=self.product_id.uom_id.id,
|
if board_room_type.price_type == 'fixed':
|
||||||
fiscal_position=False
|
return self.env['hotel.board.service.room.type.line'].search([
|
||||||
)
|
('hotel_board_service_room_type_id', '=', board_room_type.id),
|
||||||
return self.env['account.tax']._fix_tax_included_price_company(self._get_display_price(product), product.taxes_id, self.tax_ids, folio.company_id)
|
('product_id','=',self.product_id.id)]).amount
|
||||||
|
else:
|
||||||
|
return (reservation.price_total * self.env['hotel.board.service.room.type.line'].search([
|
||||||
|
('hotel_board_service_room_type_id', '=', board_room_type.id),
|
||||||
|
('product_id','=',self.product_id.id)]).amount) / 100
|
||||||
|
else:
|
||||||
|
product = self.product_id.with_context(
|
||||||
|
lang=partner.lang,
|
||||||
|
partner=partner.id,
|
||||||
|
quantity=self.product_qty,
|
||||||
|
date=folio.date_order or fields.Date.today(),
|
||||||
|
pricelist=pricelist.id,
|
||||||
|
uom=self.product_id.uom_id.id,
|
||||||
|
fiscal_position=False
|
||||||
|
)
|
||||||
|
return self.env['account.tax']._fix_tax_included_price_company(self._get_display_price(product), product.taxes_id, self.tax_ids, folio.company_id)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def prepare_service_lines(self, **kwargs):
|
def prepare_service_lines(self, **kwargs):
|
||||||
@@ -251,9 +263,12 @@ class HotelService(models.Model):
|
|||||||
"""
|
"""
|
||||||
for record in self:
|
for record in self:
|
||||||
folio = record.folio_id or self.env.context.get('default_folio_id')
|
folio = record.folio_id or self.env.context.get('default_folio_id')
|
||||||
|
reservation = record.ser_room_line or self.env.context.get('ser_room_line')
|
||||||
|
currency = folio.currency_id if folio else reservation.currency_id
|
||||||
product = record.product_id
|
product = record.product_id
|
||||||
price = record.price_unit * (1 - (record.discount or 0.0) * 0.01)
|
price = record.price_unit * (1 - (record.discount or 0.0) * 0.01)
|
||||||
taxes = record.tax_ids.compute_all(price, folio.currency_id, record.product_qty, product=product)
|
taxes = record.tax_ids.compute_all(price, currency, record.product_qty, product=product)
|
||||||
|
|
||||||
record.update({
|
record.update({
|
||||||
'price_tax': sum(t.get('amount', 0.0) for t in taxes.get('taxes', [])),
|
'price_tax': sum(t.get('amount', 0.0) for t in taxes.get('taxes', [])),
|
||||||
'price_total': taxes['total_included'],
|
'price_total': taxes['total_included'],
|
||||||
|
|||||||
@@ -17,3 +17,5 @@ access_hotel_reservation,access_hotel_reservation,model_hotel_reservation,base.g
|
|||||||
access_hotel_folio,access_hotel_folio,model_hotel_folio,base.group_user,1,0,0,0
|
access_hotel_folio,access_hotel_folio,model_hotel_folio,base.group_user,1,0,0,0
|
||||||
access_hotel_room_type,access_hotel_room_type,model_hotel_room_type,base.group_user,1,0,0,0
|
access_hotel_room_type,access_hotel_room_type,model_hotel_room_type,base.group_user,1,0,0,0
|
||||||
access_hotel_board_service_room_type,access_hotel_board_service_room_type,model_hotel_board_service_room_type,base.group_user,1,0,0,0
|
access_hotel_board_service_room_type,access_hotel_board_service_room_type,model_hotel_board_service_room_type,base.group_user,1,0,0,0
|
||||||
|
access_hotel_board_service_room_type_line,access_hotel_board_service_room_type_line,model_hotel_board_service_room_type_line,base.group_user,1,0,0,0
|
||||||
|
access_hotel_board_service_line,access_hotel_board_service_line,model_hotel_board_service_line,base.group_user,1,0,0,0
|
||||||
|
|||||||
|
30
hotel/views/hotel_board_service_room_type_views.xml
Normal file
30
hotel/views/hotel_board_service_room_type_views.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="hotel_board_service_room_type_form">
|
||||||
|
<field name="name">hotel.board.service.room.type.form</field>
|
||||||
|
<field name="model">hotel.board.service.room.type</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Board Service Line">
|
||||||
|
<group>
|
||||||
|
<field name="amount"/>
|
||||||
|
<field name="board_service_line_ids">
|
||||||
|
<tree editable="bottom">
|
||||||
|
<field name="hotel_board_service_room_type_id" invisible="1"/>
|
||||||
|
<field name="product_id"/>
|
||||||
|
<field name="amount" />
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</group>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.actions.act_window" id="action_hotel_board_service_room_type_view">
|
||||||
|
<field name="name">Hotel Board Service</field>
|
||||||
|
<field name="res_model">hotel.board.service.room.type</field>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
@@ -3,20 +3,20 @@
|
|||||||
|
|
||||||
<!--==================================================== Board Services ==================================================== -->
|
<!--==================================================== Board Services ==================================================== -->
|
||||||
<!-- Form view of hotel board service -->
|
<!-- Form view of hotel board service -->
|
||||||
<record model="ir.ui.view" id="hotel_board_service_view_form">
|
<record model="ir.ui.view" id="hotel_board_service_form">
|
||||||
<field name="name">hotel.board.service.form</field>
|
<field name="name">hotel.board.service.form</field>
|
||||||
<field name="model">hotel.board.service</field>
|
<field name="model">hotel.board.service</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Hotel Board Service">
|
<form string="Board Service Line">
|
||||||
<sheet>
|
<group>
|
||||||
<group>
|
<field name="amount"/>
|
||||||
<field name="name" select="1" />
|
<field name="board_service_line_ids">
|
||||||
<field name="sequence" />
|
<tree editable="bottom">
|
||||||
</group>
|
<field name="product_id"/>
|
||||||
<group>
|
<field name="amount" />
|
||||||
<field name="service_ids" />
|
</tree>
|
||||||
</group>
|
</field>
|
||||||
</sheet>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Hotel Board Services">
|
<tree string="Hotel Board Services">
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="sequence" />
|
<field name="amount" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -298,7 +298,9 @@
|
|||||||
<field name="arrival_hour"/>
|
<field name="arrival_hour"/>
|
||||||
<field name="departure_hour"/>
|
<field name="departure_hour"/>
|
||||||
<field name="nights" invisible="1"/>
|
<field name="nights" invisible="1"/>
|
||||||
<field name="board_service_id" />
|
<field name="board_service_room_id" domain="[
|
||||||
|
('hotel_room_type_id', '=', room_type_id),
|
||||||
|
('pricelist_id', 'in', [pricelist_id, False])]" />
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="adults"/>
|
<field name="adults"/>
|
||||||
<field name="children"/>
|
<field name="children"/>
|
||||||
|
|||||||
@@ -191,7 +191,10 @@
|
|||||||
<field name="arrival_hour"/>
|
<field name="arrival_hour"/>
|
||||||
<field name="departure_hour"/>
|
<field name="departure_hour"/>
|
||||||
<field name="nights" invisible="1"/>
|
<field name="nights" invisible="1"/>
|
||||||
<field name="board_service_id" />
|
<!-- TODO: How to filter to avoid show False (generic) pricelist board when exist a specific pricelist board¿? -->
|
||||||
|
<field name="board_service_room_id" domain="[
|
||||||
|
('hotel_room_type_id', '=', room_type_id),
|
||||||
|
('pricelist_id', 'in', [pricelist_id, False])]" />
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="adults"/>
|
<field name="adults"/>
|
||||||
<field name="children"/>
|
<field name="children"/>
|
||||||
@@ -237,11 +240,16 @@
|
|||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="days" string="Service and Days">
|
<page name="days" string="Service and Days">
|
||||||
<group string="Reservation Services" name="reservation_services" attrs="{'invisible': [('folio_id','=',False)]}">
|
<group string="Reservation Services" name="reservation_services">
|
||||||
<field name="service_ids"
|
<field name="service_ids"
|
||||||
context="{'default_ser_room_line': active_id, 'default_folio_id': folio_id}"
|
context="{'default_ser_room_line': active_id, 'default_folio_id': folio_id}"
|
||||||
nolabel="1">
|
nolabel="1">
|
||||||
<tree string="Services" editable="bottom">
|
<tree string="Services" editable="bottom"
|
||||||
|
decoration-success="is_board_service == True">
|
||||||
|
<button type="object" class="oe_stat_button"
|
||||||
|
id="included_in_room" icon="fa fa-1x fa-bed"
|
||||||
|
name="open_service_lines"
|
||||||
|
attrs="{'invisible':[('is_board_service','=', False)]}" />
|
||||||
<!-- <field name="sequence" widget="handle"/> -->
|
<!-- <field name="sequence" widget="handle"/> -->
|
||||||
<field name="per_day" invisible="1"/>
|
<field name="per_day" invisible="1"/>
|
||||||
<field name="is_board_service" invisible="1" />
|
<field name="is_board_service" invisible="1" />
|
||||||
|
|||||||
@@ -46,6 +46,9 @@
|
|||||||
<field name="price_type" />
|
<field name="price_type" />
|
||||||
<field name="amount" />
|
<field name="amount" />
|
||||||
<field name="pricelist_id" />
|
<field name="pricelist_id" />
|
||||||
|
<button type="object" class="oe_stat_button"
|
||||||
|
id="go_board_lines" icon="fa fa-2x fa-bars"
|
||||||
|
name="open_board_lines_form"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
|
|||||||
Reference in New Issue
Block a user