mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Onboard service line basic workflow
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
'views/hotel_board_service_views.xml',
|
||||
'views/hotel_checkin_partner_views.xml',
|
||||
'views/hotel_room_type_availability_views.xml',
|
||||
'views/hotel_board_service_room_type.xml',
|
||||
'data/cron_jobs.xml',
|
||||
'data/records.xml',
|
||||
'data/email_template_cancel.xml',
|
||||
|
||||
@@ -29,3 +29,4 @@ from . import hotel_room_type_class
|
||||
from . import hotel_room_closure_reason
|
||||
from . import hotel_service_line
|
||||
from . import hotel_board_service
|
||||
from . import hotel_board_service_room_type_line
|
||||
|
||||
@@ -21,7 +21,11 @@ class HotelBoardServiceRoomType(models.Model):
|
||||
price_type = fields.Selection([
|
||||
('fixed','Fixed'),
|
||||
('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
|
||||
def init(self):
|
||||
@@ -29,6 +33,52 @@ class HotelBoardServiceRoomType(models.Model):
|
||||
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)')
|
||||
|
||||
@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
|
||||
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)
|
||||
today = fields.Date.today()
|
||||
for product in board_service.service_ids:
|
||||
cmds.append((0, False, {
|
||||
'service_id': product.id,
|
||||
'amount': product.list_price #TODO: default amomunt?¿
|
||||
}))
|
||||
return {'board_service_line_ids': cmds}
|
||||
|
||||
@api.constrains('pricelist_id')
|
||||
def constrains_pricelist_id(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)
|
||||
service_id = fields.Many2one(
|
||||
'product.product', 'Product', required=True, readonly=True)
|
||||
amount = fields.Float('Amount', digits=dp.get_precision('Product Price'), default=0.0)
|
||||
|
||||
|
||||
|
||||
30
hotel/views/hotel_board_service_room_type.xml
Normal file
30
hotel/views/hotel_board_service_room_type.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="service_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>
|
||||
@@ -46,6 +46,9 @@
|
||||
<field name="price_type" />
|
||||
<field name="amount" />
|
||||
<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>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user