From 2b40bad6fbc47ff6ec7b11e6996e7aae09abd2c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Lodeiros?= Date: Fri, 23 Oct 2020 09:26:42 +0200 Subject: [PATCH] [WIP] Multiproperty --- pms/models/res_users.py | 10 ++++++++++ pms/security/pms_security.xml | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/pms/models/res_users.py b/pms/models/res_users.py index e43fb3856..bb8e21fff 100644 --- a/pms/models/res_users.py +++ b/pms/models/res_users.py @@ -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 diff --git a/pms/security/pms_security.xml b/pms/security/pms_security.xml index 17347f9e6..030bd20ea 100644 --- a/pms/security/pms_security.xml +++ b/pms/security/pms_security.xml @@ -34,21 +34,23 @@ - + + ['|',('pms_property_id','=',False),('pms_property_id', 'in', + user.get_active_property_ids())] + +