mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
Multiproperty Constrains (#30)
* [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>
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
# Copyright 2017 Alexandre Díaz
|
||||
# Copyright 2017 Dario Lodeiros
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
pms_property_ids = fields.Many2many(
|
||||
"pms.property", string="Properties", required=False, ondelete="restrict"
|
||||
comodel_name="pms.property",
|
||||
relation="product_template_property_rel",
|
||||
column1="product_tmpl_id",
|
||||
column2="property_id",
|
||||
string="Properties",
|
||||
required=False,
|
||||
ondelete="restrict",
|
||||
)
|
||||
per_day = fields.Boolean("Unit increment per day")
|
||||
per_person = fields.Boolean("Unit increment per person")
|
||||
@@ -24,3 +31,16 @@ class ProductTemplate(models.Model):
|
||||
default=False,
|
||||
help="Specifies if the product is shown in the calendar information.",
|
||||
)
|
||||
|
||||
@api.constrains("pms_property_ids", "company_id")
|
||||
def _check_property_company_integrity(self):
|
||||
for rec in self:
|
||||
if rec.company_id and rec.pms_property_ids:
|
||||
property_companies = rec.pms_property_ids.mapped("company_id")
|
||||
if len(property_companies) > 1 or rec.company_id != property_companies:
|
||||
raise ValidationError(
|
||||
_(
|
||||
"The company of the properties must match "
|
||||
"the company on the room type"
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user