Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Arturo Jasso Origel
/
helpdesk
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a5f45368
authored
a year ago
by
Arturo Jasso Origel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
se han agregado permisos y se han acomodado el dashboard para el conteo
parent
431e2cfa
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
324 additions
and
3 deletions
+324
-3
helpdesk_morsa/models/__init__.py
+1
-0
helpdesk_morsa/models/helpdesk_team.py
+1
-1
helpdesk_morsa/models/helpdesk_ticket.py
+1
-1
helpdesk_morsa/models/ticket_dashboard.py
+290
-0
helpdesk_morsa/security/groups.xml
+25
-1
helpdesk_morsa/views/odoo/helpdesk_team.xml
+3
-0
helpdesk_morsa/views/odoo/helpdesk_ticket.xml
+3
-0
No files found.
helpdesk_morsa/models/__init__.py
View file @
a5f45368
...
...
@@ -8,3 +8,4 @@ from . import helpdesk_team
from
.
import
helpdesk_ticket
from
.
import
helpdesk_settings
from
.
import
helpdesk_sla
from
.
import
ticket_dashboard
This diff is collapsed.
Click to expand it.
helpdesk_morsa/models/helpdesk_team.py
View file @
a5f45368
...
...
@@ -8,7 +8,7 @@ class HelpdeskTeamInherit(models.Model):
short_name
=
fields
.
Char
(
'Nombre corto'
,
copy
=
False
)
sequence_id
=
fields
.
Many2one
(
'ir.sequence'
,
string
=
"Sequencia"
,
copy
=
False
)
is_support_team
=
fields
.
Boolean
(
'Equipo de soporte'
)
team_admin_id
=
fields
.
Many2one
(
'res.users'
,
string
=
"Administrador del equipo"
)
@api.onchange
(
short_name
)
def
convert_short_name_upper
(
self
):
...
...
This diff is collapsed.
Click to expand it.
helpdesk_morsa/models/helpdesk_ticket.py
View file @
a5f45368
...
...
@@ -45,7 +45,7 @@ class HelpdeskTicket(models.Model):
common_scenery
=
fields
.
Char
(
"¿Qué escenarios son comunes a trabajar con esta transacción?"
)
module_impact
=
fields
.
Char
(
"¿Tu solicitud, impacta de algún modo a algún otro Módulo?"
)
system_id
=
fields
.
Many2one
(
'erp.system'
,
'Sistema'
)
team_admin_id
=
fields
.
Many2one
(
'res.users'
,
string
=
"Administrador del equipo"
,
related
=
'team_id.team_admin_id'
)
def
_get_color
(
self
):
...
...
This diff is collapsed.
Click to expand it.
helpdesk_morsa/models/ticket_dashboard.py
0 → 100644
View file @
a5f45368
# -*- coding: utf-8 -*-
from
odoo
import
models
,
fields
,
api
from
odoo.http
import
request
from
datetime
import
datetime
from
dateutil.relativedelta
import
relativedelta
from
odoo.tools
import
DEFAULT_SERVER_DATE_FORMAT
import
json
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
class
TicketDashboardInherit
(
models
.
Model
):
_inherit
=
'ticket.dashboard'
@api.model
def
get_team_leader
(
self
):
uid
=
request
.
session
.
uid
user
=
request
.
env
[
'res.users'
]
.
sudo
()
.
browse
(
uid
)
cids
=
request
.
httprequest
.
cookies
.
get
(
'cids'
,
str
(
user
.
company_id
.
id
))
cids
=
[
int
(
cid
)
for
cid
in
cids
.
split
(
','
)]
domain
=
[
(
'company_ids'
,
'in'
,
cids
),
(
'share'
,
'='
,
False
)
]
teams
=
self
.
env
[
'helpdesk.team'
]
.
sudo
()
.
search
([])
team_heads
=
list
(
teams
.
mapped
(
'team_head'
)
.
ids
+
teams
.
mapped
(
'team_admin_id'
)
.
ids
)
_logger
.
info
(
team_heads
)
domain
.
append
((
'id'
,
'in'
,
team_heads
))
users
=
self
.
env
[
'res.users'
]
.
sudo
()
.
search_read
(
domain
)
return
users
@api.model
def
get_ticket_counter_data
(
self
,
team_leader
,
team
,
assign_user
,
filter_date
,
start_date
,
end_date
):
data_dict
=
{}
ticket_data_dic
=
{}
ticket_data_list
=
[]
ticket_obj
=
self
.
env
[
'helpdesk.ticket'
]
.
sudo
()
.
search
(
[],
order
=
'id desc'
,
limit
=
1
)
uid
=
request
.
session
.
uid
user
=
self
.
env
[
'res.users'
]
.
sudo
()
.
browse
(
uid
)
cids
=
request
.
httprequest
.
cookies
.
get
(
'cids'
,
str
(
user
.
company_id
.
id
))
cids
=
[
int
(
cid
)
for
cid
in
cids
.
split
(
','
)]
company_id
=
self
.
env
.
company
id_list
=
[]
for
stage
in
company_id
.
dashboard_filter
:
doman
=
[]
id_list
=
[]
if
filter_date
==
'today'
:
dt_flt1
=
[]
dt_flt1
.
append
(
'create_date'
)
dt_flt1
.
append
(
'>'
)
dt_flt1
.
append
(
datetime
.
now
()
.
date
()
.
strftime
(
"
%
Y/
%
m/
%
d 00:00:00"
))
doman
.
append
(
tuple
(
dt_flt1
))
dt_flt2
=
[]
dt_flt2
.
append
(
'create_date'
)
dt_flt2
.
append
(
'<='
)
dt_flt2
.
append
(
datetime
.
now
()
.
date
()
.
strftime
(
"
%
Y/
%
m/
%
d 23:59:59"
))
doman
.
append
(
tuple
(
dt_flt2
))
elif
filter_date
==
'yesterday'
:
dt_flt1
=
[]
dt_flt1
.
append
(
'create_date'
)
dt_flt1
.
append
(
'>'
)
prev_day
=
(
datetime
.
now
()
.
date
()
-
relativedelta
(
days
=
1
))
.
strftime
(
'
%
Y/
%
m/
%
d 00:00:00'
)
dt_flt1
.
append
(
prev_day
)
doman
.
append
(
tuple
(
dt_flt1
))
dt_flt2
=
[]
dt_flt2
.
append
(
'create_date'
)
dt_flt2
.
append
(
'<='
)
prev_day
=
(
datetime
.
now
()
.
date
()
-
relativedelta
(
days
=
1
))
.
strftime
(
'
%
Y/
%
m/
%
d 23:59:59'
)
dt_flt2
.
append
(
prev_day
)
doman
.
append
(
tuple
(
dt_flt2
))
elif
filter_date
==
'weekly'
:
# current week
dt_flt1
=
[]
dt_flt1
.
append
(
'create_date'
)
dt_flt1
.
append
(
'>'
)
dt_flt1
.
append
((
datetime
.
now
()
.
date
(
)
-
relativedelta
(
weeks
=
1
,
weekday
=
0
))
.
strftime
(
"
%
Y/
%
m/
%
d 00:00:00"
))
doman
.
append
(
tuple
(
dt_flt1
))
dt_flt2
=
[]
dt_flt2
.
append
(
'create_date'
)
dt_flt2
.
append
(
'<='
)
dt_flt2
.
append
(
datetime
.
now
()
.
date
()
.
strftime
(
"
%
Y/
%
m/
%
d 23:59:59"
))
doman
.
append
(
tuple
(
dt_flt2
))
elif
filter_date
==
'prev_week'
:
# Previous week
dt_flt1
=
[]
dt_flt1
.
append
(
'create_date'
)
dt_flt1
.
append
(
'>'
)
dt_flt1
.
append
((
datetime
.
now
()
.
date
(
)
-
relativedelta
(
weeks
=
2
,
weekday
=
0
))
.
strftime
(
"
%
Y/
%
m/
%
d 00:00:00"
))
doman
.
append
(
tuple
(
dt_flt1
))
dt_flt2
=
[]
dt_flt2
.
append
(
'create_date'
)
dt_flt2
.
append
(
'<='
)
dt_flt2
.
append
((
datetime
.
now
()
.
date
(
)
-
relativedelta
(
weeks
=
1
,
weekday
=
6
))
.
strftime
(
"
%
Y/
%
m/
%
d 23:59:59"
))
doman
.
append
(
tuple
(
dt_flt2
))
elif
filter_date
==
'monthly'
:
# Current Month
dt_flt1
=
[]
dt_flt1
.
append
(
'create_date'
)
dt_flt1
.
append
(
'>'
)
dt_flt1
.
append
(
(
datetime
.
now
()
.
date
())
.
strftime
(
"
%
Y/
%
m/01 00:00:00"
))
doman
.
append
(
tuple
(
dt_flt1
))
dt_flt2
=
[]
dt_flt2
.
append
(
'create_date'
)
dt_flt2
.
append
(
'<='
)
dt_flt2
.
append
(
datetime
.
now
()
.
date
()
.
strftime
(
"
%
Y/
%
m/
%
d 23:59:59"
))
doman
.
append
(
tuple
(
dt_flt2
))
elif
filter_date
==
'prev_month'
:
# Previous Month
dt_flt1
=
[]
dt_flt1
.
append
(
'create_date'
)
dt_flt1
.
append
(
'>'
)
dt_flt1
.
append
(
(
datetime
.
now
()
.
date
()
-
relativedelta
(
months
=
1
))
.
strftime
(
"
%
Y/
%
m/01 00:00:00"
))
doman
.
append
(
tuple
(
dt_flt1
))
dt_flt2
=
[]
dt_flt2
.
append
(
'create_date'
)
dt_flt2
.
append
(
'<'
)
dt_flt2
.
append
(
datetime
.
now
()
.
date
()
.
strftime
(
"
%
Y/
%
m/01 00:00:00"
))
doman
.
append
(
tuple
(
dt_flt2
))
elif
filter_date
==
'cur_year'
:
# Current Year
dt_flt1
=
[]
dt_flt1
.
append
(
'create_date'
)
dt_flt1
.
append
(
'>'
)
dt_flt1
.
append
(
(
datetime
.
now
()
.
date
())
.
strftime
(
"
%
Y/01/01 00:00:00"
))
doman
.
append
(
tuple
(
dt_flt1
))
dt_flt2
=
[]
dt_flt2
.
append
(
'create_date'
)
dt_flt2
.
append
(
'<='
)
dt_flt2
.
append
(
datetime
.
now
()
.
date
()
.
strftime
(
"
%
Y/
%
m/
%
d 23:59:59"
))
doman
.
append
(
tuple
(
dt_flt2
))
elif
filter_date
==
'prev_year'
:
# Previous Year
dt_flt1
=
[]
dt_flt1
.
append
(
'create_date'
)
dt_flt1
.
append
(
'>'
)
dt_flt1
.
append
(
(
datetime
.
now
()
.
date
()
-
relativedelta
(
years
=
1
))
.
strftime
(
"
%
Y/01/01 00:00:00"
))
doman
.
append
(
tuple
(
dt_flt1
))
dt_flt2
=
[]
dt_flt2
.
append
(
'create_date'
)
dt_flt2
.
append
(
'<'
)
dt_flt2
.
append
(
datetime
.
now
()
.
date
()
.
strftime
(
"
%
Y/01/01 00:00:00"
))
doman
.
append
(
tuple
(
dt_flt2
))
elif
filter_date
==
'custom'
:
if
start_date
and
end_date
:
dt_flt1
=
[]
dt_flt1
.
append
(
'create_date'
)
dt_flt1
.
append
(
'>='
)
dt_flt1
.
append
(
datetime
.
strptime
(
str
(
start_date
),
DEFAULT_SERVER_DATE_FORMAT
)
.
strftime
(
"
%
Y/
%
m/
%
d"
))
doman
.
append
(
tuple
(
dt_flt1
))
dt_flt2
=
[]
dt_flt2
.
append
(
'create_date'
)
dt_flt2
.
append
(
'<='
)
dt_flt2
.
append
(
datetime
.
strptime
(
str
(
end_date
),
DEFAULT_SERVER_DATE_FORMAT
)
.
strftime
(
"
%
Y/
%
m/
%
d"
))
doman
.
append
(
tuple
(
dt_flt2
))
if
team
and
team
not
in
[
None
,
False
,
""
]
and
int
(
team
)
!=
0
:
doman
.
append
((
'team_id'
,
'='
,
int
(
team
)))
elif
team
and
team
not
in
[
None
,
False
,
""
]
and
int
(
team
)
==
0
:
if
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_team_leader'
)
and
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_user'
)
and
not
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_manager'
):
team_ids
=
self
.
env
[
'helpdesk.team'
]
.
sudo
()
.
search
(
[
'|'
,(
'team_head'
,
'='
,
self
.
env
.
user
.
id
),
(
'team_members'
,
'in'
,
[
self
.
env
.
user
.
id
])])
doman
.
append
((
'team_id'
,
'in'
,
team_ids
.
ids
))
elif
not
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_team_leader'
)
and
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_user'
)
and
not
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_manager'
):
team_ids
=
self
.
env
[
'helpdesk.team'
]
.
sudo
()
.
search
(
[(
'team_members'
,
'in'
,
[
self
.
env
.
user
.
id
])])
doman
.
append
((
'team_id'
,
'in'
,
team_ids
.
ids
))
"""
if self.env.user.has_group('helpdesk_morsa.ticket_team_admin'):
doman.append(('|'))
doman.append(('team_admin_id','=',self.env.user.id))
doman.append(('team_admin_id','=',False))
"""
if
team_leader
and
team_leader
not
in
[
None
,
False
,
""
]
and
int
(
team_leader
)
!=
0
:
doman
.
append
((
'team_head'
,
'='
,
int
(
team_leader
)))
elif
team_leader
and
team_leader
not
in
[
None
,
False
,
""
]
and
int
(
team_leader
)
==
0
:
if
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_team_leader'
)
and
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_user'
)
and
not
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_manager'
):
doman
.
append
((
'|'
))
doman
.
append
((
'|'
))
doman
.
append
((
'team_head'
,
'='
,
self
.
env
.
user
.
id
))
doman
.
append
((
'user_id'
,
'='
,
self
.
env
.
user
.
id
))
doman
.
append
((
'sh_user_ids'
,
'in'
,
[
self
.
env
.
user
.
id
]))
if
assign_user
and
assign_user
not
in
[
None
,
False
,
""
]
and
int
(
assign_user
)
!=
0
:
doman
.
append
((
'|'
))
doman
.
append
((
'user_id'
,
'='
,
int
(
assign_user
)))
doman
.
append
((
'sh_user_ids'
,
'in'
,
[
int
(
assign_user
)]))
elif
assign_user
and
assign_user
not
in
[
None
,
False
,
""
]
and
int
(
assign_user
)
==
0
:
if
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_team_leader'
)
and
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_user'
)
and
not
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_manager'
):
doman
.
append
((
'|'
))
doman
.
append
((
'|'
))
doman
.
append
((
'sh_user_ids'
,
'in'
,
[
self
.
env
.
user
.
id
]))
doman
.
append
((
'user_id'
,
'='
,
self
.
env
.
user
.
id
))
doman
.
append
((
'team_head'
,
'='
,
self
.
env
.
user
.
id
))
elif
not
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_team_leader'
)
and
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_user'
)
and
not
self
.
env
.
user
.
has_group
(
'sh_all_in_one_helpdesk.helpdesk_group_manager'
):
doman
.
append
((
'|'
))
doman
.
append
((
'user_id'
,
'='
,
self
.
env
.
user
.
id
))
doman
.
append
((
'sh_user_ids'
,
'in'
,
[
self
.
env
.
user
.
id
]))
ticket_list
=
[]
doman
.
append
((
'stage_id'
,
'='
,
stage
.
id
))
doman
.
append
((
'company_id'
,
'in'
,
cids
))
#CHANCE DOMAN
if
self
.
env
.
user
.
has_group
(
'helpdesk_morsa.ticket_team_admin'
):
doman
=
[]
doman
.
append
((
'stage_id'
,
'='
,
stage
.
id
))
doman
.
append
((
'company_id'
,
'in'
,
cids
))
doman
.
append
((
'|'
))
doman
.
append
((
'team_admin_id'
,
'='
,
self
.
env
.
user
.
id
))
doman
.
append
((
'team_admin_id'
,
'='
,
False
))
search_tickets
=
ticket_obj
.
search
(
doman
)
_logger
.
info
(
search_tickets
)
if
search_tickets
:
for
ticket
in
search_tickets
:
create_date
=
datetime
.
strftime
(
ticket
.
create_date
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
write_date
=
datetime
.
strftime
(
ticket
.
write_date
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
ticket_dic
=
{
'ticket_id'
:
ticket
.
id
,
'ticket_no'
:
ticket
.
name
,
'partner_id'
:
ticket
.
partner_id
.
name
,
'create_date'
:
create_date
,
'write_date'
:
write_date
,
'user_id'
:
ticket
.
user_id
.
name
,
}
ticket_list
.
append
(
ticket_dic
)
id_list
.
append
(
ticket
.
id
)
search_stage
=
self
.
env
[
'helpdesk.stages'
]
.
sudo
()
.
search
([
(
'id'
,
'='
,
stage
.
id
)
],
limit
=
1
)
ticket_wrong
=
0
if
search_stage
:
ticket_data_dic
.
update
({
search_stage
.
name
:
ticket_list
})
tickt
=
self
.
env
[
'helpdesk.ticket'
]
.
sudo
()
.
search
([(
'stage_id'
,
'='
,
search_stage
.
id
)])
if
tickt
.
filtered
(
lambda
x
:
x
.
color
==
9
):
ticket_wrong
=
1
elif
tickt
.
filtered
(
lambda
x
:
x
.
color
==
3
):
ticket_wrong
=
3
list_ids
=
[
id_list
,
ticket_wrong
]
data_dict
.
update
({
search_stage
.
name
:
[
list_ids
,
ticket_wrong
]})
ticket_data_list
.
append
(
search_stage
.
name
)
_logger
.
info
(
doman
)
return
self
.
env
[
'ir.ui.view'
]
.
with_context
()
.
_render_template
(
'sh_all_in_one_helpdesk.ticket_dashboard_count'
,
{
'ticket_data_dic'
:
ticket_data_dic
,
'ticket_data_list'
:
ticket_data_list
,
'data_dict'
:
data_dict
,
})
\ No newline at end of file
This diff is collapsed.
Click to expand it.
helpdesk_morsa/security/groups.xml
View file @
a5f45368
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data
noupdate=
"1"
>
<data>
<record
id=
"ticket_auditor"
model=
"res.groups"
>
...
...
@@ -8,6 +8,29 @@
<field
name=
"name"
>
Auditor de tickets
</field>
</record>
<record
id=
"ticket_team_admin"
model=
"res.groups"
>
<field
name=
"category_id"
ref=
"sh_all_in_one_helpdesk.module_helpdesk_category"
/>
<field
name=
"name"
>
Administrador del equipo
</field>
<field
name=
"implied_ids"
eval=
"[(4, ref('sh_all_in_one_helpdesk.helpdesk_group_team_leader'))]"
/>
</record>
<record
model=
"ir.rule"
id=
"helpdesk_team_admin"
>
<field
name=
"name"
>
Helpdesk Administrador del equipo
</field>
<field
name=
"model_id"
ref=
"sh_all_in_one_helpdesk.model_helpdesk_team"
/>
<field
name=
"global"
eval=
"True"
/>
<field
name=
"domain_force"
>
['|',('team_admin_id','=',user.id),('team_admin_id','=',False)]
</field>
<field
name=
"groups"
eval=
"[(4, ref('helpdesk_morsa.ticket_team_admin'))]"
/>
</record>
<record
model=
"ir.rule"
id=
"helpdesk_ticket_team_admin"
>
<field
name=
"name"
>
Helpdesk Ticket Team Admin
</field>
<field
name=
"model_id"
ref=
"sh_all_in_one_helpdesk.model_helpdesk_ticket"
/>
<field
name=
"global"
eval=
"True"
/>
<field
name=
"domain_force"
>
['|',('team_admin_id','=',user.id),('team_admin_id','=',False)]
</field>
<field
name=
"groups"
eval=
"[(4, ref('helpdesk_morsa.ticket_team_admin'))]"
/>
</record>
</data>
</odoo>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
helpdesk_morsa/views/odoo/helpdesk_team.xml
View file @
a5f45368
...
...
@@ -9,6 +9,9 @@
<xpath
expr=
"//field[@name='name']"
position=
"after"
>
<field
name=
"short_name"
required=
"1"
/>
</xpath>
<xpath
expr=
"//field[@name='team_head']"
position=
"after"
>
<field
name=
"team_admin_id"
/>
</xpath>
</field>
</record>
</data>
...
...
This diff is collapsed.
Click to expand it.
helpdesk_morsa/views/odoo/helpdesk_ticket.xml
View file @
a5f45368
...
...
@@ -7,6 +7,9 @@
<field
name=
"inherit_id"
ref=
"sh_all_in_one_helpdesk.helpdesk_ticket_form_view"
/>
<field
name=
"priority"
eval=
"17"
/>
<field
name=
"arch"
type=
"xml"
>
<xpath
expr=
"//field[@name='team_head']"
position=
"after"
>
<field
name=
"team_admin_id"
/>
</xpath>
<xpath
expr=
"//field[@name='name']"
position=
"after"
>
<field
name=
"is_support"
invisible=
"1"
/>
<field
name=
"is_erp"
invisible=
"1"
/>
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment