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.

22 lines
898 B

  1. # Copyright 2021 Tecnativa - David Vidal
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  3. from odoo.addons.portal.controllers.portal import CustomerPortal
  4. from odoo.http import request, route
  5. class PortalBlockEdit(CustomerPortal):
  6. def _prepare_portal_layout_values(self):
  7. """So we can change the edit link text in the view"""
  8. values = super()._prepare_portal_layout_values()
  9. values["block_portal_data_edit"] = (
  10. request.env.user.block_portal_data_edit)
  11. return values
  12. @route()
  13. def account(self, redirect=None, **post):
  14. """Inject a context that we later we catch in the template `render`"""
  15. if request.env.user.block_portal_data_edit:
  16. context = dict(request.env.context, block_portal_data_edit=True)
  17. request.env.context = context
  18. return super().account(redirect, **post)