[ADD] Hotel Room Type Class basic structure: model, views and relations

This commit is contained in:
Dario Lodeiros
2018-10-25 13:40:11 +02:00
parent 2f7af67723
commit 8d8defe92d
6 changed files with 88 additions and 1 deletions

View File

@@ -43,6 +43,7 @@
# 'views/hotel_service_line.xml',
'views/hotel_room_type.xml',
'views/hotel_room.xml',
'views/hotel_room_type_class.xml',
# 'views/hotel_service.xml',
'views/inherit_product_product.xml',
'views/hotel_room_amenities_type.xml',

View File

@@ -30,4 +30,5 @@ from . import inherit_product_pricelist
from . import res_config
from . import inherit_res_partner
from . import inherited_mail_compose_message
from . import hotel_room_type_class
#~ from . import hotel_dashboard

View File

@@ -5,7 +5,7 @@ from odoo import models, fields, api
class HotelRoomType(models.Model):
""" Before creating a 'room type', you need to consider the following:
With the term 'room type' is meant a type of residential accommodation: for
With the term 'room type' is meant a sales type of residential accommodation: for
example, a Double Room, a Economic Room, an Apartment, a Tent, a Caravan...
"""
_name = "hotel.room.type"
@@ -17,6 +17,7 @@ class HotelRoomType(models.Model):
required=True, delegate=True,
ondelete='cascade')
room_ids = fields.One2many('hotel.room', 'room_type_id', 'Rooms')
class_id = fields.Many2one('hotel.room.type.class', 'Hotel Type Class')
# TODO Hierarchical relationship for parent-child tree ?
# parent_id = fields.Many2one ...

View File

@@ -0,0 +1,24 @@
# 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
class HotelRoomTypeClass(models.Model):
""" Before creating a 'room type_class', you need to consider the following:
With the term 'room type class' is meant a physicial class of
residential accommodation: for example, a Room, a Bed, an Apartment,
a Tent, a Caravan...
"""
_name = "hotel.room.type.class"
_description = "Room Type Class"
_order = "sequence, code_class, name"
_sql_constraints = [('code_type_unique', 'unique(code_type)',
'code must be unique!')]
name = fields.Char('Class Name', required=True, translate=True)
room_type_ids = fields.One2many('hotel.room.type', 'class_id', 'Types')
active = fields.Boolean('Active', default=True,
help="The active field allows you to hide the \
category without removing it.")
sequence = fields.Integer('Sequence', default=0)
code_class = fields.Char('Code')

View File

@@ -22,6 +22,7 @@
<field name="list_price" widget='monetary' options="{'currency_field': 'currency_id', 'field_digits': True}"/>
</group>
<group>
<field name="class_id" />
<field name="total_rooms_count"/>
</group>
</group>

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Form view of hotel room type class-->
<record model="ir.ui.view" id="view_hotel_room_type_class_form">
<field name="name">hotel.room.type.class.form</field>
<field name="model">hotel.room.type.class</field>
<field name="arch" type="xml">
<form string="Hotel Room Type">
<sheet>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<group colspan="4">
<group>
<field name="name" />
<field name="code_class" />
</group>
</group>
<group colspan="2">
<group>
<field name="room_type_ids" widget="many2many"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<!-- Tree view of hotel room type class -->
<record model="ir.ui.view" id="view_hotel_room_type_class_tree">
<field name="name">hotel.room.type.class.tree</field>
<field name="model">hotel.room.type.class</field>
<field name="arch" type="xml">
<tree string=" Hotel Room Type Class">
<field name="sequence" widget="handle"/>
<field name="name" />
<field name="code_class"/>
<field name="room_type_ids"/>
</tree>
</field>
</record>
<!-- Action for hotel room type class -->
<record model="ir.actions.act_window" id="open_hotel_room_type_class_form_tree">
<field name="name">Room Type Class</field>
<field name="res_model">hotel.room.type.class</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem name="Type Class" id="menu_open_hotel_room_type_class_form_tree"
action="open_hotel_room_type_class_form_tree" sequence="15"
parent="hotel.menu_hotel_room" />
</odoo>