diff --git a/hotel_node_master/__init__.py b/hotel_node_master/__init__.py index 69f7babdf..7588e52c8 100644 --- a/hotel_node_master/__init__.py +++ b/hotel_node_master/__init__.py @@ -1,3 +1,4 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models +from . import wizards diff --git a/hotel_node_master/__manifest__.py b/hotel_node_master/__manifest__.py index 59ea26b09..88ed89063 100644 --- a/hotel_node_master/__manifest__.py +++ b/hotel_node_master/__manifest__.py @@ -18,6 +18,7 @@ 'views/hotel_node_user.xml', 'views/hotel_node_group.xml', 'views/hotel_node_room_type.xml', + 'wizards/wizard_hotel_node_reservation.xml', 'security/hotel_node_security.xml', 'security/ir.model.access.csv' ], diff --git a/hotel_node_master/models/hotel_node.py b/hotel_node_master/models/hotel_node.py index e473a3b5c..2cb8adb3c 100644 --- a/hotel_node_master/models/hotel_node.py +++ b/hotel_node_master/models/hotel_node.py @@ -57,6 +57,7 @@ class HotelNode(models.Model): """ for node in self: 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) if len(invalid_groups) > 0: msg = _("At least one group is not within the node version.") + " " + \ diff --git a/hotel_node_master/models/hotel_node_user.py b/hotel_node_master/models/hotel_node_user.py index 8c4c20ad2..7da26092a 100644 --- a/hotel_node_master/models/hotel_node_user.py +++ b/hotel_node_master/models/hotel_node_user.py @@ -29,40 +29,23 @@ class HotelNodeUser(models.Model): node_id = fields.Many2one('project.project', 'Hotel', required=True) # remote users are managed as partners into the central node partner_id = fields.Many2one('res.partner', required=True) - # Remote login for the hotels login = fields.Char(require=True, help="Used to log into the hotel") - # Password for login into the remote hotels 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.") - # Remote user id for client-server understanding remote_user_id = fields.Integer(require=True, invisible=True, copy=False, readonly=True, 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', string='Groups', default=_default_groups, require=True, 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 @api.constrains('group_ids') def _check_group_ids(self): # TODO ensure all group_ids are within the node 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) if len(invalid_groups) > 0: msg = _("At least one group is not within the node version.") + " " + \ @@ -91,6 +74,7 @@ class HotelNodeUser(models.Model): if 'group_ids' in vals: domain = [('id', 'in', vals['group_ids'][0][2]), ('odoo_version', '!=', node.odoo_version)] invalid_groups = self.env["hotel.node.group"].search(domain) + # TODO Use search_count if len(invalid_groups) > 0: msg = _("At least one group is not within the node version.") + " " + \ _("Odoo version in node: %s") % node.odoo_version @@ -144,6 +128,7 @@ class HotelNodeUser(models.Model): if 'group_ids' in vals: domain = [('id', 'in', vals['group_ids'][0][2]), ('odoo_version', '!=', node.odoo_version)] invalid_groups = self.env["hotel.node.group"].search(domain) + # TODO Use search_count if len(invalid_groups) > 0: msg = _("At least one group is not within the node version.") + " " + \ _("Odoo version in node: %s") % node.odoo_version diff --git a/hotel_node_master/views/hotel_node.xml b/hotel_node_master/views/hotel_node.xml index 23eb01416..a0a923591 100644 --- a/hotel_node_master/views/hotel_node.xml +++ b/hotel_node_master/views/hotel_node.xml @@ -133,6 +133,12 @@ res_model="hotel.node.group" view_mode="tree,form" /> + + + + + diff --git a/hotel_node_master/wizards/__init__.py b/hotel_node_master/wizards/__init__.py new file mode 100644 index 000000000..8463c3d08 --- /dev/null +++ b/hotel_node_master/wizards/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import wizard_hotel_node_reservation diff --git a/hotel_node_master/wizards/wizard_hotel_node_reservation.py b/hotel_node_master/wizards/wizard_hotel_node_reservation.py new file mode 100644 index 000000000..e59e5fa4f --- /dev/null +++ b/hotel_node_master/wizards/wizard_hotel_node_reservation.py @@ -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') + diff --git a/hotel_node_master/wizards/wizard_hotel_node_reservation.xml b/hotel_node_master/wizards/wizard_hotel_node_reservation.xml new file mode 100644 index 000000000..84382a9f9 --- /dev/null +++ b/hotel_node_master/wizards/wizard_hotel_node_reservation.xml @@ -0,0 +1,35 @@ + + + + + hotel.node.reservation.wizard + hotel.node.reservation.wizard + +
+ +
+

+ +

+
+ + + + + + + + + + + +
+
+
+
+ +