mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Multiproperty
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# Copyright 2019 Pablo Quesada
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import api, fields, models
|
||||
from odoo.http import request
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
@@ -27,3 +28,12 @@ class ResUsers(models.Model):
|
||||
string="Properties",
|
||||
default=_get_default_pms_property,
|
||||
)
|
||||
|
||||
@api.model
|
||||
def get_active_property_ids(self):
|
||||
# TODO: Require performance test and security
|
||||
# checks (Review lazy_property decorator?)
|
||||
active_property_ids = list(
|
||||
map(int, request.httprequest.cookies.get("pms_pids", "").split(","))
|
||||
)
|
||||
return active_property_ids
|
||||
|
||||
@@ -34,21 +34,23 @@
|
||||
</field>
|
||||
</record>
|
||||
<!-- Property Rules -->
|
||||
<!--<record id="pms_folio_property_rule" model="ir.rule">
|
||||
<record id="pms_folio_property_rule" model="ir.rule">
|
||||
<field name="name">PMS Folio Company Rule</field>
|
||||
<field name="model_id" ref="model_pms_folio" />
|
||||
<field name="global" eval="True" />
|
||||
<field
|
||||
name="domain_force"
|
||||
>['|',('pms_property_id','=',False),('pms_property_id', 'in', property_ids)]</field>
|
||||
<field name="domain_force">
|
||||
['|',('pms_property_id','=',False),('pms_property_id', 'in',
|
||||
user.get_active_property_ids())]
|
||||
</field>
|
||||
</record>
|
||||
<record id="pms_reservation_property_rule" model="ir.rule">
|
||||
<field name="name">PMS Reservation Company Rule</field>
|
||||
<field name="model_id" ref="model_pms_reservation" />
|
||||
<field name="global" eval="True" />
|
||||
<field
|
||||
name="domain_force"
|
||||
>['|',('pms_property_id','=',False),('pms_property_id', 'in', property_ids)]</field>
|
||||
</record>-->
|
||||
<field name="domain_force">
|
||||
['|',('pms_property_id','=',False),('pms_property_id', 'in',
|
||||
user.get_active_property_ids())]
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user