[IMP] Views Shared room

This commit is contained in:
Dario Lodeiros
2021-08-11 12:15:27 +02:00
parent 2c7dae07cb
commit d2a45b70ef
4 changed files with 70 additions and 51 deletions

View File

@@ -470,34 +470,3 @@ class PmsReservationLine(models.Model):
)
if duplicated:
raise ValidationError(_("Duplicated reservation line date"))
@api.constrains("room_id", "date")
def constrains_parent_room_avail(self):
for record in self:
if record.room_id and record.room_id.parent_id and record.date:
if self.env["pms.availability"].get_occupied_parent_rooms(
room=record.room_id.parent_id,
checkin=record.date,
checkout=record.date + datetime.timedelta(1),
pms_property_id=record.room_id.pms_property_id.id,
):
raise ValidationError(
_("Room %s is occupied in this date by the parent room %s")
% record.room_id.display_name,
record.room_id.parent_id.display_name,
)
@api.constrains("room_id", "date")
def constrains_childs_room_avail(self):
for record in self:
if record.room_id and record.room_id.child_ids and record.date:
if self.env["pms.availability"].get_occupied_child_rooms(
rooms=record.room_id.child_ids,
checkin=record.date,
checkout=record.date + datetime.timedelta(1),
pms_property_id=record.room_id.pms_property_id.id,
):
raise ValidationError(
_("Room %s is occupied in this date by the child rooms")
% record.room_id.display_name
)

View File

@@ -60,7 +60,6 @@ class PmsRoom(models.Model):
help="Child rooms of the room",
comodel_name="pms.room",
inverse_name="parent_id",
ondelete="restrict",
check_pms_properties=True,
)
ubication_id = fields.Many2one(
@@ -87,7 +86,13 @@ class PmsRoom(models.Model):
column2="amenity_id",
check_pms_properties=True,
)
is_shared_room = fields.Boolean(
string="Is a Shared Room",
help="allows you to reserve units " " smaller than the room itself (eg beds)",
compute="_compute_is_shared_room",
readonly=False,
store=True,
)
description_sale = fields.Text(
string="Sale Description",
help="A description of the Product that you want to communicate to "
@@ -105,6 +110,14 @@ class PmsRoom(models.Model):
)
]
@api.depends("child_ids")
def _compute_is_shared_room(self):
for record in self:
if record.child_ids:
record.is_shared_room = True
elif not record.is_shared_room:
record.is_shared_room = False
def name_get(self):
result = []
for room in self:
@@ -130,6 +143,17 @@ class PmsRoom(models.Model):
)
)
@api.constrains("is_shared_room")
def _check_shared_room(self):
for record in self:
if record.is_shared_room and not record.child_ids:
raise ValidationError(
_(
"The reservation units are required \
on shared rooms."
)
)
@api.model
def _check_adults(self, reservation, service_line_ids=False):
for line in reservation.reservation_line_ids:

View File

@@ -19,22 +19,22 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# from . import test_pms_reservation
# from . import test_pms_pricelist
# from . import test_pms_checkin_partner
# from . import test_pms_sale_channel
# from . import test_pms_folio
# from . import test_pms_availability_plan_rules
# from . import test_pms_room_type
# from . import test_pms_room_type_class
# from . import test_pms_board_service
# from . import test_pms_wizard_massive_changes
# from . import test_pms_booking_engine
# from . import test_pms_res_users
# from . import test_pms_room
# from . import test_pms_folio_invoice
# from . import test_pms_folio_sale_line
# from . import test_pms_wizard_split_join_swap_reservation
# from . import test_product_template
# from . import test_pms_multiproperty
from . import test_pms_reservation
from . import test_pms_pricelist
from . import test_pms_checkin_partner
from . import test_pms_sale_channel
from . import test_pms_folio
from . import test_pms_availability_plan_rules
from . import test_pms_room_type
from . import test_pms_room_type_class
from . import test_pms_board_service
from . import test_pms_wizard_massive_changes
from . import test_pms_booking_engine
from . import test_pms_res_users
from . import test_pms_room
from . import test_pms_folio_invoice
from . import test_pms_folio_sale_line
from . import test_pms_wizard_split_join_swap_reservation
from . import test_product_template
from . import test_pms_multiproperty
from . import test_shared_room

View File

@@ -38,6 +38,11 @@
<field name="ubication_id" string="Ubication" />
<!-- <field name="categ_id" select="1" domain="[('isroomtype','=',True)]" string="Room Type" /> -->
<field name="room_type_id" string="Room Type" />
<field name="is_shared_room" />
<field
name="parent_id"
attrs="{'invisible':[('parent_id', '=', False)]}"
/>
<field name="capacity" />
<field name="extra_beds_allowed" />
<!-- <field name="uom_id" invisible="1" /> -->
@@ -66,6 +71,27 @@
<page string="Amenities">
<field name="room_amenity_ids" />
</page>
<page
string="Shared Room"
attrs="{'invisible':[('is_shared_room', '=', False)]}"
>
<group>
<field
name="child_ids"
context="{'default_parent_id': active_id}"
nolabel="1"
>
<tree editable="bottom">
<field name="sequence" widget="handle" />
<field name="name" />
<field name="room_type_id" />
<field name="capacity" />
<field name="parent_id" invisible="1" />
<field name="pms_property_id" invisible="1" />
</tree>
</field>
</group>
</page>
</notebook>
<group>
<field name="sequence" />