I am trying to super the function "retrieve_dashboard" found in the python file "helpdesk.py". This is to change the view from my tickets to all tickets inside the helpdesk overview. So, I modified the domain inside the function from the main code and it worked and now I want to super the function so that I can use it in my code. This is what I did:
from odoo import api,fields,models,_ | |
from odoo.osv import expression | |
class HelpDeskTeamInh(models.Model): | |
_inherit = 'helpdesk.team' | |
@api.model | |
def retrieve_dashboard(self): | |
domain = [('user_id', '!=', self.env.uid)] | |
res=super(HelpDeskTeamInh, self).retrieve_dashboard() | |
group_fields = ['priority', 'create_date', 'stage_id', 'close_hours'] | |
list_fields = ['priority', 'create_date', 'stage_id', 'close_hours'] | |
# TODO: remove SLA calculations if user_uses_sla is false. | |
user_uses_sla = self.user_has_groups('helpdesk.group_use_sla') and \ | |
bool(self.env['helpdesk.team'].search( | |
[('use_sla', '=', True), '|', ('member_ids', 'in', self._uid), ('member_ids', '=', False)])) | |
if user_uses_sla: | |
group_fields.insert(1, 'sla_deadline:year') | |
group_fields.insert(2, 'sla_deadline:hour') | |
group_fields.insert(3, 'sla_reached_late') | |
list_fields.insert(1, 'sla_deadline') | |
list_fields.insert(2, 'sla_reached_late') | |
HelpdeskTicket = self.env['helpdesk.ticket'] | |
tickets = HelpdeskTicket.search_read(expression.AND([domain, [('stage_id.is_close', '=', False)]]), | |
['sla_deadline', 'open_hours', 'sla_reached_late', 'priority']) | |
result = { | |
'helpdesk_target_closed': self.env.user.helpdesk_target_closed, | |
'helpdesk_target_rating': self.env.user.helpdesk_target_rating, | |
'helpdesk_target_success': self.env.user.helpdesk_target_success, | |
'today': {'count': 0, 'rating': 0, 'success': 0}, | |
'7days': {'count': 0, 'rating': 0, 'success': 0}, | |
'my_all': {'count': 0, 'hours': 0, 'failed': 0}, | |
'my_high': {'count': 0, 'hours': 0, 'failed': 0}, | |
'my_urgent': {'count': 0, 'hours': 0, 'failed': 0}, | |
'show_demo': not bool(HelpdeskTicket.search([], limit=1)), | |
'rating_enable': False, | |
'success_rate_enable': user_uses_sla | |
} | |
return res |
Any Help Please?