Browse Source

fix(theme): use sudo() for SLA access in dashboard, fix login redirect to use direct partner_id

odoo 2 months ago
parent
commit
d90820cbca
2 changed files with 4 additions and 4 deletions
  1. 3 3
      theme_m22tc/controllers/helpdesk_portal.py
  2. 1 1
      theme_m22tc/controllers/main.py

+ 3 - 3
theme_m22tc/controllers/helpdesk_portal.py

@@ -191,7 +191,7 @@ class CustomerPortal(HelpdeskCustomerPortal):
         """
         Calculate SLA compliance percentage.
         """
-        tickets_with_sla = tickets.filtered(lambda t: t.sla_ids)
+        tickets_with_sla = tickets.filtered(lambda t: t.sudo().sla_ids)
         
         if not tickets_with_sla:
             return {
@@ -288,7 +288,7 @@ class CustomerPortal(HelpdeskCustomerPortal):
         for ticket in open_tickets:
             # PRIMARY: Check if in SLA excluded stage (waiting stage)
             # This is explicit and most reliable - if in excluded stage, definitely waiting
-            excluded_stages = ticket.sla_ids.mapped('exclude_stage_ids')
+            excluded_stages = ticket.sudo().sla_ids.mapped('exclude_stage_ids')
             is_in_waiting_stage = ticket.stage_id in excluded_stages
             
             if is_in_waiting_stage:
@@ -346,7 +346,7 @@ class CustomerPortal(HelpdeskCustomerPortal):
         waiting_tickets_sorted = sorted(
             waiting_tickets,
             key=lambda t: (
-                t.date_last_stage_update if t.stage_id in t.sla_ids.mapped('exclude_stage_ids')
+                t.date_last_stage_update if t.stage_id in t.sudo().sla_ids.mapped('exclude_stage_ids')
                 else last_message_map.get(t.id, request.env['mail.message']).date if last_message_map.get(t.id)
                 else t.date_last_stage_update
                 or t.create_date

+ 1 - 1
theme_m22tc/controllers/main.py

@@ -30,7 +30,7 @@ class Website(WebsiteBase):
                 if user and user._is_portal():
                     # Check if helpdesk_extras is available
                     if 'helpdesk_extras' in request.env.registry._init_modules:
-                        partner = user.partner_id.commercial_partner_id
+                        partner = user.partner_id
                         
                         # Check if user is a collaborator in any helpdesk team
                         is_collaborator = (