mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Wizard Node Reservation
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
# 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 . import models
|
from . import models
|
||||||
|
from . import wizards
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
'views/hotel_node_user.xml',
|
'views/hotel_node_user.xml',
|
||||||
'views/hotel_node_group.xml',
|
'views/hotel_node_group.xml',
|
||||||
'views/hotel_node_room_type.xml',
|
'views/hotel_node_room_type.xml',
|
||||||
|
'wizards/wizard_hotel_node_reservation.xml',
|
||||||
'security/hotel_node_security.xml',
|
'security/hotel_node_security.xml',
|
||||||
'security/ir.model.access.csv'
|
'security/ir.model.access.csv'
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class HotelNode(models.Model):
|
|||||||
"""
|
"""
|
||||||
for node in self:
|
for node in self:
|
||||||
domain = [('id', 'in', node.group_ids.ids), ('odoo_version', '!=', node.odoo_version)]
|
domain = [('id', 'in', node.group_ids.ids), ('odoo_version', '!=', node.odoo_version)]
|
||||||
|
# TODO Use search_count
|
||||||
invalid_groups = self.env["hotel.node.group"].search(domain)
|
invalid_groups = self.env["hotel.node.group"].search(domain)
|
||||||
if len(invalid_groups) > 0:
|
if len(invalid_groups) > 0:
|
||||||
msg = _("At least one group is not within the node version.") + " " + \
|
msg = _("At least one group is not within the node version.") + " " + \
|
||||||
|
|||||||
@@ -29,40 +29,23 @@ class HotelNodeUser(models.Model):
|
|||||||
node_id = fields.Many2one('project.project', 'Hotel', required=True)
|
node_id = fields.Many2one('project.project', 'Hotel', required=True)
|
||||||
# remote users are managed as partners into the central node
|
# remote users are managed as partners into the central node
|
||||||
partner_id = fields.Many2one('res.partner', required=True)
|
partner_id = fields.Many2one('res.partner', required=True)
|
||||||
# Remote login for the hotels
|
|
||||||
login = fields.Char(require=True,
|
login = fields.Char(require=True,
|
||||||
help="Used to log into the hotel")
|
help="Used to log into the hotel")
|
||||||
# Password for login into the remote hotels
|
|
||||||
password = fields.Char(default='', invisible=True, copy=False,
|
password = fields.Char(default='', invisible=True, copy=False,
|
||||||
help="Keep empty if you don't want the user to be able to connect on the hotel.")
|
help="Keep empty if you don't want the user to be able to connect on the hotel.")
|
||||||
# Remote user id for client-server understanding
|
|
||||||
remote_user_id = fields.Integer(require=True, invisible=True, copy=False, readonly=True,
|
remote_user_id = fields.Integer(require=True, invisible=True, copy=False, readonly=True,
|
||||||
help="ID of the target record in the remote database")
|
help="ID of the target record in the remote database")
|
||||||
|
|
||||||
# The same user can not be assigned to the same hotel
|
|
||||||
# _sql_constraints = [
|
|
||||||
# ('user_id_node_id_key', 'UNIQUE (user_id, node_id)',
|
|
||||||
# 'You can not have two users with the same login in the same hotel!')
|
|
||||||
# ]
|
|
||||||
|
|
||||||
# Users access control ...
|
|
||||||
group_ids = fields.Many2many('hotel.node.group', 'hotel_node_user_group_rel', 'user_id', 'group_id',
|
group_ids = fields.Many2many('hotel.node.group', 'hotel_node_user_group_rel', 'user_id', 'group_id',
|
||||||
string='Groups', default=_default_groups, require=True,
|
string='Groups', default=_default_groups, require=True,
|
||||||
help="Access rights for this user in this hotel.")
|
help="Access rights for this user in this hotel.")
|
||||||
|
|
||||||
# @api.constrains('user_id', 'node_id')
|
|
||||||
# def _check_user_node_unicity(self):
|
|
||||||
# if self.search_count([
|
|
||||||
# ('user_id', '=', self.user_id.id),
|
|
||||||
# ('node_id', '=', self.node_id.id),
|
|
||||||
# ]) > 1:
|
|
||||||
# raise ValidationError(_("You can not have two users with the same login in the same hotel!"))
|
|
||||||
|
|
||||||
# Constraints and onchanges
|
# Constraints and onchanges
|
||||||
@api.constrains('group_ids')
|
@api.constrains('group_ids')
|
||||||
def _check_group_ids(self):
|
def _check_group_ids(self):
|
||||||
# TODO ensure all group_ids are within the node version
|
# TODO ensure all group_ids are within the node version
|
||||||
domain = [('id', 'in', self.group_ids.ids), ('odoo_version', '!=', self.node_id.odoo_version)]
|
domain = [('id', 'in', self.group_ids.ids), ('odoo_version', '!=', self.node_id.odoo_version)]
|
||||||
|
# TODO Use search_count
|
||||||
invalid_groups = self.env["hotel.node.group"].search(domain)
|
invalid_groups = self.env["hotel.node.group"].search(domain)
|
||||||
if len(invalid_groups) > 0:
|
if len(invalid_groups) > 0:
|
||||||
msg = _("At least one group is not within the node version.") + " " + \
|
msg = _("At least one group is not within the node version.") + " " + \
|
||||||
@@ -91,6 +74,7 @@ class HotelNodeUser(models.Model):
|
|||||||
if 'group_ids' in vals:
|
if 'group_ids' in vals:
|
||||||
domain = [('id', 'in', vals['group_ids'][0][2]), ('odoo_version', '!=', node.odoo_version)]
|
domain = [('id', 'in', vals['group_ids'][0][2]), ('odoo_version', '!=', node.odoo_version)]
|
||||||
invalid_groups = self.env["hotel.node.group"].search(domain)
|
invalid_groups = self.env["hotel.node.group"].search(domain)
|
||||||
|
# TODO Use search_count
|
||||||
if len(invalid_groups) > 0:
|
if len(invalid_groups) > 0:
|
||||||
msg = _("At least one group is not within the node version.") + " " + \
|
msg = _("At least one group is not within the node version.") + " " + \
|
||||||
_("Odoo version in node: %s") % node.odoo_version
|
_("Odoo version in node: %s") % node.odoo_version
|
||||||
@@ -144,6 +128,7 @@ class HotelNodeUser(models.Model):
|
|||||||
if 'group_ids' in vals:
|
if 'group_ids' in vals:
|
||||||
domain = [('id', 'in', vals['group_ids'][0][2]), ('odoo_version', '!=', node.odoo_version)]
|
domain = [('id', 'in', vals['group_ids'][0][2]), ('odoo_version', '!=', node.odoo_version)]
|
||||||
invalid_groups = self.env["hotel.node.group"].search(domain)
|
invalid_groups = self.env["hotel.node.group"].search(domain)
|
||||||
|
# TODO Use search_count
|
||||||
if len(invalid_groups) > 0:
|
if len(invalid_groups) > 0:
|
||||||
msg = _("At least one group is not within the node version.") + " " + \
|
msg = _("At least one group is not within the node version.") + " " + \
|
||||||
_("Odoo version in node: %s") % node.odoo_version
|
_("Odoo version in node: %s") % node.odoo_version
|
||||||
|
|||||||
@@ -133,6 +133,12 @@
|
|||||||
res_model="hotel.node.group"
|
res_model="hotel.node.group"
|
||||||
view_mode="tree,form"
|
view_mode="tree,form"
|
||||||
/>
|
/>
|
||||||
|
<!-- Action to open Hotel Node Reservation List -->
|
||||||
|
<act_window id="hotel_node_reservation_action"
|
||||||
|
name="List of Reservations in Hotels"
|
||||||
|
res_model="hotel.node.reservation.wizard"
|
||||||
|
view_mode="tree,form"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- Menu default to open Hotel Nodes Dashboard -->
|
<!-- Menu default to open Hotel Nodes Dashboard -->
|
||||||
<menuitem id="hotel_node_dashboard_menu"
|
<menuitem id="hotel_node_dashboard_menu"
|
||||||
@@ -172,4 +178,12 @@
|
|||||||
parent="dashboard_menu"
|
parent="dashboard_menu"
|
||||||
sequence="3"
|
sequence="3"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- Menu item to open Hotel Node Reservation List -->
|
||||||
|
<menuitem id="hotel_node_reservation_menu"
|
||||||
|
name="Reservations"
|
||||||
|
action="hotel_node_reservation_action"
|
||||||
|
parent="dashboard_menu"
|
||||||
|
sequence="4"
|
||||||
|
/>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
3
hotel_node_master/wizards/__init__.py
Normal file
3
hotel_node_master/wizards/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from . import wizard_hotel_node_reservation
|
||||||
22
hotel_node_master/wizards/wizard_hotel_node_reservation.py
Normal file
22
hotel_node_master/wizards/wizard_hotel_node_reservation.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Copyright 2018 Pablo Q. Barriuso
|
||||||
|
# Copyright 2018 Alexandre Díaz
|
||||||
|
# Copyright 2018 Dario Lodeiros
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from odoo import models, fields, api, _
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class HotelNodeReservationWizard(models.TransientModel):
|
||||||
|
_name = "hotel.node.reservation.wizard"
|
||||||
|
_description = "Hotel Node Reservation Wizard"
|
||||||
|
|
||||||
|
node_id = fields.Many2one('project.project', 'Hotel')
|
||||||
|
|
||||||
|
room_type_id = fields.Many2one('hotel.node.room.type', 'Rooms Type')
|
||||||
|
room_type_name = fields.Char('Name', related='room_type_id.name')
|
||||||
|
|
||||||
|
room_id = fields.Many2one('hotel.node.room', 'Rooms')
|
||||||
|
|
||||||
35
hotel_node_master/wizards/wizard_hotel_node_reservation.xml
Normal file
35
hotel_node_master/wizards/wizard_hotel_node_reservation.xml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="hotel_node_reservation_wizard_view_form" model="ir.ui.view">
|
||||||
|
<field name="name">hotel.node.reservation.wizard</field>
|
||||||
|
<field name="model">hotel.node.reservation.wizard</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Users">
|
||||||
|
<sheet>
|
||||||
|
<div class="oe_title">
|
||||||
|
<h1>
|
||||||
|
<field name="node_id" placeholder="Hotel" required="1"
|
||||||
|
attrs="{'readonly': [('node_id', '!=', False)]}"/>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<group attrs="{'invisible': [('node_id', '=', False)]}">
|
||||||
|
<group name="room_type">
|
||||||
|
<field name="room_type_id">
|
||||||
|
<tree>
|
||||||
|
<field name="name" string="Room Type" readonly="1"/>
|
||||||
|
<field name="remote_room_type_id" readonly="1"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<footer attrs="{'invisible': [('node_id', '=', False)]}">
|
||||||
|
<button name="create_folio" string="Create Reservations" type="object"
|
||||||
|
class="oe_highlight" />
|
||||||
|
</footer>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user