diff --git a/base_mixin_restrict_field_access/__init__.py b/base_mixin_restrict_field_access/__init__.py index 0188fced6..7eda98a23 100644 --- a/base_mixin_restrict_field_access/__init__.py +++ b/base_mixin_restrict_field_access/__init__.py @@ -2,4 +2,3 @@ # © 2016 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models -from . import controllers diff --git a/base_mixin_restrict_field_access/controllers/__init__.py b/base_mixin_restrict_field_access/controllers/__init__.py deleted file mode 100644 index 1b21ddd33..000000000 --- a/base_mixin_restrict_field_access/controllers/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2017 Therp BV -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import main diff --git a/base_mixin_restrict_field_access/controllers/main.py b/base_mixin_restrict_field_access/controllers/main.py deleted file mode 100644 index f2632e1bf..000000000 --- a/base_mixin_restrict_field_access/controllers/main.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2017 Therp BV -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp.http import request -from openerp.addons.web.controllers.main import Export -from ..models.restrict_field_access_mixin import RestrictFieldAccessMixin - - -class RestrictedExport(Export): - """Don't (even offer to) export inaccessible fields""" - def fields_get(self, model): - fields = super(RestrictedExport, self).fields_get(model) - model = request.env[model] - if isinstance(model, RestrictFieldAccessMixin): - sanitised_fields = { - k: fields[k] for k in fields - if model._restrict_field_access_is_field_accessible(k) - } - return sanitised_fields - else: - return fields diff --git a/base_mixin_restrict_field_access/tests/test_base_mixin_restrict_field_access.py b/base_mixin_restrict_field_access/tests/test_base_mixin_restrict_field_access.py index abef5b343..6d7d181d4 100644 --- a/base_mixin_restrict_field_access/tests/test_base_mixin_restrict_field_access.py +++ b/base_mixin_restrict_field_access/tests/test_base_mixin_restrict_field_access.py @@ -95,12 +95,12 @@ class TestBaseMixinRestrictFieldAccess(TransactionCase): data = partner_model.read_group( [], [], ['user_id'] ) - self.assertEqual(data[0]['credit_limit'], 41) + self.assertEqual(sum(d['credit_limit'] for d in data), 41) # but users with permissions should see the sum for all records data = partner_model.sudo().read_group( [], [], ['user_id'] ) self.assertEqual( - data[0]['credit_limit'], + sum(d['credit_limit'] for d in data), sum(partner_model.sudo().search([]).mapped('credit_limit')) )