mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
* [IMP] add multiproperties demo data * [IMP] add multiproperties checks in res_users * [IMP] add test case in test_res_users * [IMP] Add multiproperty checks in pms_amenity and pms_amenity_type * [IMP] Add multiproperty in pms_board_service_room_type(pending review) * [IMP] Add test case in test_pms_room_type_availability_rule to check multiproperties * [IMP] Fixing test case in test_pms_room_type_availability_rule to check multiproperties * [IMP] Add test case in test_pms_room_type_availability_rule * [IMP] Removed field default_availability_plan_id from pms_property * [IMP] Add multiproperty in pms_room_type_available_plan * [IMP] pms: adding property in rooms_available * [IMP] Add multiproperty in pms_room_type_availability_rule and product_pricelist(work in progress) * [IMP] Add multiproperty in product_pricelist and product_pricelist_item * [IMP] add multiproperties demo data * [IMP] add multiproperties checks in res_users * [IMP] add test case in test_res_users and pms_room_type_availability_rule * [IMP] Add multiproperty checks in pms_amenity and pms_amenity_type * [IMP] Add multiproperty in pms_board_service_room_type(pending review) * [IMP] Removed field default_availability_plan_id from pms_property * [IMP] Add multiproperty in pms_room_type_available_plan * [IMP] pms: adding property in rooms_available * [IMP] Add multiproperty in pms_room_type_availability_rule and product_pricelist(work in progress) * [IMP] Add multiproperty in product_pricelist and product_pricelist_item * [IMP] Pms: add compute_folio method in pms.service * [IMP] Pms: add multiproperty integrity checks between room_type and its class * [IMP] Pms: pms_property_id related to folio * [IMP] Pms: add multiproperty integrity checks in pms_room with pms_room_type and pms_floor * [IMP] Pms: adding multiproperty checks in room_type(work in progress) * [IMP] Pms: Add property rules * [FIX]pms: external ids security rules * [FIX]pms: property checks * [FIX]pms: get product on pricelist item multiproperty check * [FIX]pms: delete test field default_plan * [FIX]pms: property constrain to product from room type model * [FIX]pms: ids references * [IMP]pms: folio wizard price flow on odoo standar Co-authored-by: Darío Lodeiros <dario@commitsun.com>
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
# Copyright 2017 Alexandre Díaz
|
|
# Copyright 2017 Dario Lodeiros
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
from odoo import _, api, fields, models
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
class PmsRoomAmenity(models.Model):
|
|
_name = "pms.amenity"
|
|
_description = "Room amenities"
|
|
|
|
# Fields declaration
|
|
name = fields.Char("Amenity Name", translate=True, required=True)
|
|
pms_property_ids = fields.Many2many(
|
|
"pms.property", string="Properties", required=False, ondelete="restrict"
|
|
)
|
|
room_amenity_type_id = fields.Many2one("pms.amenity.type", "Amenity Category")
|
|
default_code = fields.Char("Internal Reference")
|
|
active = fields.Boolean("Active", default=True)
|
|
|
|
# TODO: Constrain coherence pms_property_ids with amenity types pms_property_ids
|
|
allowed_property_ids = fields.Many2many(
|
|
"pms.property",
|
|
"allowed_amenity_move_rel",
|
|
"amenity_id",
|
|
"property_id",
|
|
string="Allowed Properties",
|
|
store=True,
|
|
readonly=True,
|
|
compute="_compute_allowed_property_ids",
|
|
)
|
|
|
|
@api.depends(
|
|
"room_amenity_type_id.pms_property_ids",
|
|
)
|
|
def _compute_allowed_property_ids(self):
|
|
for amenity in self:
|
|
if amenity.room_amenity_type_id.pms_property_ids:
|
|
amenity.allowed_property_ids = (
|
|
amenity.room_amenity_type_id.pms_property_ids
|
|
)
|
|
else:
|
|
amenity.allowed_property_ids = False
|
|
|
|
@api.constrains(
|
|
"allowed_property_ids",
|
|
"pms_property_ids",
|
|
)
|
|
def _check_property_integrity(self):
|
|
for rec in self:
|
|
if rec.pms_property_ids and rec.allowed_property_ids:
|
|
for prop in rec.pms_property_ids:
|
|
if prop not in rec.allowed_property_ids:
|
|
raise ValidationError(_("Property not allowed"))
|