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.

23 lines
820 B

  1. # Copyright (C) 2021 Open Source Integrators
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import models
  4. from odoo.http import request
  5. class IrHttp(models.AbstractModel):
  6. _inherit = "ir.http"
  7. def session_info(self):
  8. """
  9. Based on the selected companies (cids),
  10. calculate the roles to enable.
  11. A role should be enabled only when it applies to all selected companies.
  12. """
  13. result = super(IrHttp, self).session_info()
  14. if self.env.user.role_line_ids:
  15. cids_str = request.httprequest.cookies.get("cids", str(self.env.company.id))
  16. cids = [int(cid) for cid in cids_str.split(",")]
  17. self.env.user._set_session_active_roles(cids)
  18. self.env.user.set_groups_from_roles()
  19. return result