mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
* [WIP]pms: models check_pms_property * [WIP][IMP+REF] multi_pms_properties: refactor and added test skeleton * [FIX] inherit create models * [ADD] room multiproperty check * [ADD] room multiproperty check * [IMP] Multiproperty checks in pms models * [IMP] Fix Multiproperty checks in pms models * [IMP] Add multiproperty domain in multi_pms_properties module * [IMP] Fix multiproperty checks in pms tests * [IMP] Fix multiproperty checks logic * [IMP] Auto Domains * [IMP] availability property results, domain preferred_room_id * [IMP] model domain properties * [ADD] pms multiproperty depends * [IMP] models and views multiproperty checks * [FIX] Multiple rebase multiproperty fixes * [ADD] Readme * [ADD] Company - multiproperty checks * [ADD] travis server wide modules multiproperty * [FIX] travis conf load * [FIX] travis conf load2 * [FIX] travis conf load2 Co-authored-by: Eric Antones <eantones@nuobit.com> Co-authored-by: Sara Lago <saralago126@gmail.com>
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
# 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 PmsUbication(models.Model):
|
|
_name = "pms.ubication"
|
|
_description = "Ubication"
|
|
_check_pms_properties_auto = True
|
|
|
|
name = fields.Char(
|
|
string="Ubication Name",
|
|
help="Ubication Name",
|
|
required=True,
|
|
translate=True,
|
|
)
|
|
sequence = fields.Integer(
|
|
string="Sequence",
|
|
help="Field used to change the position of the ubications in tree view."
|
|
"Changing the position changes the sequence",
|
|
)
|
|
pms_property_ids = fields.Many2many(
|
|
string="Properties",
|
|
help="Properties with access to the element;"
|
|
" if not set, all properties can access",
|
|
comodel_name="pms.property",
|
|
relation="pms_ubication_pms_property_rel",
|
|
column1="ubication_type_id",
|
|
column2="pms_property_id",
|
|
ondelete="restrict",
|
|
check_pms_properties=True,
|
|
)
|
|
pms_room_ids = fields.One2many(
|
|
string="Rooms",
|
|
help="Rooms found in this location",
|
|
comodel_name="pms.room",
|
|
inverse_name="ubication_id",
|
|
check_pms_properties=True,
|
|
)
|
|
|
|
@api.constrains(
|
|
"pms_property_ids",
|
|
"pms_room_ids",
|
|
)
|
|
def _check_property_integrity(self):
|
|
for rec in self:
|
|
if rec.pms_property_ids and rec.pms_room_ids:
|
|
if rec.pms_room_ids.pms_property_id not in rec.pms_property_ids:
|
|
raise ValidationError(_("Property not allowed"))
|