You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
813 B

  1. # -*- coding: utf-8 -*-
  2. # © 2017 Therp BV <http://therp.nl>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp.http import request
  5. from openerp.addons.web.controllers.main import Export
  6. from ..models.restrict_field_access_mixin import RestrictFieldAccessMixin
  7. class RestrictedExport(Export):
  8. """Don't (even offer to) export inaccessible fields"""
  9. def fields_get(self, model):
  10. fields = super(RestrictedExport, self).fields_get(model)
  11. model = request.env[model]
  12. if isinstance(model, RestrictFieldAccessMixin):
  13. sanitised_fields = {
  14. k: fields[k] for k in fields
  15. if model._restrict_field_access_is_field_accessible(k)
  16. }
  17. return sanitised_fields
  18. else:
  19. return fields