mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD]multi_pms_properties (#66)
* [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>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
# 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
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
@@ -17,6 +16,11 @@ class ProductTemplate(models.Model):
|
||||
relation="product_template_pms_property_rel",
|
||||
column1="product_tmpl_id",
|
||||
column2="pms_property_id",
|
||||
ondelete="restrict",
|
||||
check_pms_properties=True,
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
check_pms_properties=True,
|
||||
)
|
||||
per_day = fields.Boolean(
|
||||
string="Unit increment per day",
|
||||
@@ -40,16 +44,3 @@ class ProductTemplate(models.Model):
|
||||
help="Indicates if that product is a extra bed, add +1 capacity in the room",
|
||||
default=False,
|
||||
)
|
||||
|
||||
@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