[IMP] pms: wizard unify line room ids

This commit is contained in:
padomi
2020-11-12 19:12:22 +01:00
parent cf2241c4fb
commit ab339823b2
10 changed files with 73 additions and 10 deletions

View File

@@ -1,5 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
# from . import wizard
from . import wizards

View File

@@ -63,6 +63,7 @@
"views/product_template_views.xml",
"views/webclient_templates.xml",
"views/ir_sequence_views.xml",
"wizards/wizard_reservation.xml",
],
"demo": [
"demo/pms_master_data.xml",

View File

@@ -106,6 +106,7 @@ class PmsReservation(models.Model):
# required=True,
)
priority = fields.Integer(compute="_compute_priority", store="True", index=True)
preferred_room_id = fields.Many2one(
"pms.room",
string="Room",
@@ -785,6 +786,24 @@ class PmsReservation(models.Model):
"target": "new",
}
def open_reservation_wizard(self):
rooms_available = self.env["pms.room.type.availability"].rooms_available(
checkin=self.checkin,
checkout=self.checkout,
current_lines=self.reservation_line_ids.ids,
)
# REVIEW: check capacity room
return {
'view_type': 'form',
'view_mode': 'form',
'name': 'Unify the reservation',
'res_model': 'pms.reservation.wizard',
'target': 'new',
'type': 'ir.actions.act_window',
'context': {'rooms_available': rooms_available.ids,
}
}
# ORM Overrides
@api.model
def name_search(self, name="", args=None, operator="ilike", limit=100):

View File

@@ -123,7 +123,6 @@ class PmsReservationLine(models.Model):
# otherwise we assign the first of those available for the entire stay
else:
line.room_id = rooms_available[0]
line.reservation_id.preferred_room_id = line.room_id.id
# if there is no availability for the entire stay without changing rooms (we assume a split reservation)
else:

View File

@@ -47,3 +47,4 @@ manager_access_pms_board_service_line,manager_access_pms_board_service_line,mode
manager_access_property,manager_access_property,model_pms_property,pms.group_pms_manager,1,1,1,1
manager_access_pms_cancelation_rule,manager_access_pms_cancelation_rule,model_pms_cancelation_rule,pms.group_pms_manager,1,1,1,1
manager_access_availability,manager_access_availability,model_pms_room_type_availability,pms.group_pms_manager,1,1,1,1
user_access_pms_reservation_wizard,user_access_pms_reservation_wizard,model_pms_reservation_wizard,pms.group_pms_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
47 manager_access_property manager_access_property model_pms_property pms.group_pms_manager 1 1 1 1
48 manager_access_pms_cancelation_rule manager_access_pms_cancelation_rule model_pms_cancelation_rule pms.group_pms_manager 1 1 1 1
49 manager_access_availability manager_access_availability model_pms_room_type_availability pms.group_pms_manager 1 1 1 1
50 user_access_pms_reservation_wizard user_access_pms_reservation_wizard model_pms_reservation_wizard pms.group_pms_user 1 1 1 1

View File

@@ -377,7 +377,7 @@ class TestPmsReservations(TestHotel):
@freeze_time("1980-11-01")
def test_split_reservation06(self):
"""
The preferred room_id is not available
There's no availability in the preferred_room_id provided
+------------+------+------+------+----+----+----+
| room/date | 01 | 02 | 03 | 04 | 05 | 06 |
+------------+------+------+------+----+----+----+
@@ -419,7 +419,7 @@ class TestPmsReservations(TestHotel):
@freeze_time("1980-11-01")
def test_split_reservation07(self):
"""
The preferred room_type_id is not available
There's no availability
+------------+------+------+------+----+----+----+
| room/date | 01 | 02 | 03 | 04 | 05 | 06 |
+------------+------+------+------+----+----+----+

View File

@@ -66,14 +66,13 @@
style="margin-bottom:0px;"
attrs="{'invisible': [('splitted','=',False)]}"
>
This reservation is part of splitted reservation!, you can check it
in the
This reservation is part of splitted reservation, you can try to unify the reservation here
<bold>
<button
class="alert-link"
type="object"
name="open_folio"
string="Folio Form"
name="open_reservation_wizard"
string="Unify the reservation"
/>
</bold>
</div>
@@ -167,8 +166,10 @@
options="{'no_create': True,'no_open': True}"
placeholder="Room"
style="margin-right: 30px;"
required='1'
attrs="{'invisible': [('splitted','=',True)]}"
/>
<field
name="partner_id"
default_focus="1"

1
pms/wizards/__init__.py Normal file
View File

@@ -0,0 +1 @@
from . import wizard_reservation

View File

@@ -0,0 +1,18 @@
from odoo import models, fields
class ReservationWizard(models.TransientModel):
_name = 'pms.reservation.wizard'
allowed_rooms = fields.One2many('pms.room', compute="_compute_allowed_rooms")
options = fields.Many2one('pms.room', string='Room')
def _compute_allowed_rooms(self):
for record in self:
record.allowed_rooms = self._context.get('rooms_available')
def unify(self):
if self.options:
for record in self:
for line in self.env['pms.reservation'].search([('id', '=', self._context.get('active_id'))]).reservation_line_ids:
line.room_id = self.options

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" ?>
<odoo>
<record id="reservation_wizard" model="ir.ui.view">
<field name="name">Reservation Wizard</field>
<field name="model">pms.reservation.wizard</field>
<field name="arch" type="xml">
<form string="Choose The Details">
<group>
<field name="options"
string="Suggested rooms to unify the reservation:"
options="{'no_create': True,'no_open': True}"
required="1"
domain="[('id', 'in', allowed_rooms)]"/>
<field name="allowed_rooms" invisible="1"/>
</group>
<footer>
<button name="unify" string="Unify" type="object" class="oe_highlight" />
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
</odoo>