Commit 1804d8fb by Arturo Jasso Origel

cambios en la estructura de carpetas y modelos

parent 38d3fb9c
......@@ -11,21 +11,21 @@
"version":"15.0.34",
"depends": [
"base",
"portal_design_helpdesk",
"sh_all_in_one_helpdesk",
"vista_backend_theme",
"hide_odoo",
],
"data": [
'security/ir.model.access.csv',
'data/helpdesk_team.xml',
'data/helpdesk_stage.xml',
'data/sla_policies.xml',
'data/modules.xml',
'data/warehouses.xml',
'data/ticket_reason.xml',
'security/ir.model.access.csv',
'views/portal/portal_login.xml',
'views/portal/portal_layout.xml',
'views/portal/portal_my.xml',
'views/portal/portal_my_ti.xml',
'views/portal/portal_tickets_emergency.xml',
'views/portal/portal_tickets_erp.xml',
'views/portal/portal_tickets_support.xml',
......
from . import portal
from . import portal_soporte
from . import portal_erp
from . import portal_emergency
from . import main
\ No newline at end of file
......@@ -20,934 +20,21 @@ from odoo.addons.sh_all_in_one_helpdesk.controllers.portal import PortalHelpdesk
class PortalHelpdeskMorsa(PortalHelpdesk):
def _prepare_portal_layout_values(self):
values = super(PortalHelpdesk, self)._prepare_portal_layout_values()
stage_close = request.env.ref('sh_all_in_one_helpdesk.close_stage').id
stage_done = request.env.ref('sh_all_in_one_helpdesk.done_stage').id
stage_cancel = request.env.ref('sh_all_in_one_helpdesk.cancel_stage').id
ticket_domain = [('stage_id.id','not in',[stage_close,stage_done,stage_cancel])]
def _prepare_home_portal_values(self):
if request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'user':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'leader':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'manager':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('user_id', '=', False))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('sh_user_ids', '=', False))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
ticket_domain.append(('team_head', '=', False))
else:
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
new_domain_sup = AND([self.prepare_technial_support(), ticket_domain])
new_domain_erp = AND([self.prepare_portal_layout_erp_asistence(), ticket_domain])
new_domain_ti = AND([self.prepare_portal_layout_911(), ticket_domain])
ticket_count = request.env['helpdesk.ticket'].sudo().search_count(
ticket_domain)
support_count = len(request.env['helpdesk.ticket'].sudo().search(new_domain_sup))
erp_count = len(request.env['helpdesk.ticket'].sudo().search(new_domain_erp))
ti_count = len(request.env['helpdesk.ticket'].sudo().search(new_domain_ti))
tickets = request.env['helpdesk.ticket'].sudo().search(ticket_domain)
values['ticket_count'] = ticket_count
values['support_count'] = support_count
values['erp_count'] = erp_count
values['ti_count'] = ti_count
values['tickets'] = tickets
values['description_support'] = "Obtenga ayuda de TI"
values['description_erp'] = "Operaciones"
values['description_ti'] = "Emergencias"
values['avatar_support'] = '/helpdesk_morsa/static/src/img/support.svg'
values['avatar_erp'] = '/helpdesk_morsa/static/src/img/erp.svg'
values['avatar_emergency'] = '/helpdesk_morsa/static/src/img/emergency.svg'
return values
def prepare_technial_support(self):
domain = [('team_id.id','=',request.env.ref('helpdesk_morsa.techinnical_support').id)
]
return domain
def prepare_portal_layout_erp_asistence(self):
domain = [('team_id.id','=',request.env.ref('helpdesk_morsa.erp_asistense').id)]
return domain
def prepare_portal_layout_911(self):
domain = [('team_id.id','=',request.env.ref('helpdesk_morsa.ti_emergency').id)]
return domain
@http.route(['/my/soporte', '/my/soporte/page/<int:page>'],type='http',auth="user",website=True)
def portal_my_soporte(self,ctr='show',page=1,sortby=None,filterby=None,search=None,search_in='all',groupby='create_by',**kw):
values = self._prepare_portal_layout_values()
HelpdeskTicket = request.env['helpdesk.ticket'].sudo()
#domain = self._prepare_technial_support()
searchbar_sortings = {
'create_date': {
'label': _('Newest'),
'order': 'create_date desc'
},
'name': {
'label': _('Name'),
'order': 'name'
},
}
searchbar_inputs = {
'all': {
'input': 'all',
'label': _('Search in All')
},
}
searchbar_groupby = {
'create_by': {
'input': 'create_by',
'label': _('Created By')
},
'ticket_type': {
'input': 'ticket_type',
'label': _('Ticket Type')
},
'status': {
'input': 'status',
'label': _('Status')
},
'customer': {
'input': 'customer',
'label': _('Customer')
},
'category': {
'input': 'category',
'label': _('Category')
},
'subcategory': {
'input': 'subcategory',
'label': _('Sub Category')
},
'subject': {
'input': 'subject',
'label': _('Subject')
},
'priority': {
'input': 'priority',
'label': _('Priority')
},
'state': {
'input': 'state',
'label': _('Reply Status')
},
}
today = fields.Date.today()
quarter_start, quarter_end = date_utils.get_quarter(today)
last_week = today + relativedelta(weeks=-1)
last_month = today + relativedelta(months=-1)
last_year = today + relativedelta(years=-1)
return {}
searchbar_filters = {
'all': {
'label': _('All'),
'domain': []
},
'today': {
'label': _('Today'),
'domain': [("create_date", "=", today)]
},
'week': {
'label':
_('This week'),
'domain':
[('create_date', '>=', date_utils.start_of(today, "week")),
('create_date', '<=', date_utils.end_of(today, 'week'))]
},
'month': {
'label':
_('This month'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'month')),
('create_date', '<=', date_utils.end_of(today, 'month'))]
},
'year': {
'label':
_('This year'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'year')),
('create_date', '<=', date_utils.end_of(today, 'year'))]
},
'quarter': {
'label':
_('This Quarter'),
'domain': [('create_date', '>=', quarter_start),
('create_date', '<=', quarter_end)]
},
'last_week': {
'label':
_('Last week'),
'domain':
[('create_date', '>=', date_utils.start_of(last_week, "week")),
('create_date', '<=', date_utils.end_of(last_week, 'week'))]
},
'last_month': {
'label':
_('Last month'),
'domain':
[('create_date', '>=',
date_utils.start_of(last_month, 'month')),
('create_date', '<=', date_utils.end_of(last_month, 'month'))]
},
'last_year': {
'label':
_('Last year'),
'domain':
[('create_date', '>=', date_utils.start_of(last_year, 'year')),
('create_date', '<=', date_utils.end_of(last_year, 'year'))]
},
}
# default sort by value
if not sortby:
sortby = 'create_date'
order = searchbar_sortings[sortby]['order']
# default filter by value
if not filterby:
filterby = 'all'
domain = AND([searchbar_filters[filterby]['domain']])
if search and search_in:
domain = AND([domain, [('name', 'ilike', search)]])
ticket_domain = self.prepare_technial_support()
if request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'user':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'leader':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'manager':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('sh_user_ids', '=', False))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('user_id', '=', False))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
ticket_domain.append(('team_head', '=', False))
else:
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
stage_close = request.env.ref('sh_all_in_one_helpdesk.close_stage').id
stage_done = request.env.ref('sh_all_in_one_helpdesk.done_stage').id
stage_cancel = request.env.ref('sh_all_in_one_helpdesk.cancel_stage').id
ticket_domain.append(('stage_id.id','not in',[stage_close,stage_done,stage_cancel]))
domain = AND([domain, ticket_domain])
support_count = len(HelpdeskTicket.search(domain).filtered(lambda h: h.team_id.id == request.env.ref('helpdesk_morsa.techinnical_support').id))
# pager
pager = portal_pager(url="/my/soporte",url_args={'sortby': sortby,'search_in': search_in,'search': search,'filterby': filterby},total=support_count,page=page,step=self._items_per_page)
if groupby == 'create_by':
order = "create_uid, %s" % order
elif groupby == 'ticket_type':
order = "ticket_type, %s" % order
elif groupby == 'status':
order = "stage_id, %s" % order
elif groupby == 'customer':
order = "partner_id, %s" % order
elif groupby == 'category':
order = "category_id, %s" % order
elif groupby == 'subcategory':
order = "sub_category_id, %s" % order
elif groupby == 'subject':
order = "subject_id, %s" % order
elif groupby == 'priority':
order = "priority, %s" % order
elif groupby == 'state':
order = 'state,%s' % order
tickets = HelpdeskTicket.search(domain,
order=order,
limit=self._items_per_page,
offset=pager['offset'])
request.session['my_tickets_history'] = tickets.ids[:100]
if groupby == 'create_by':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('create_uid'))
]
elif groupby == 'ticket_type':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('ticket_type'))
]
elif groupby == 'status':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('stage_id'))
]
elif groupby == 'customer':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('partner_id'))
]
elif groupby == 'category':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('category_id'))
]
elif groupby == 'subcategory':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('sub_category_id'))
]
elif groupby == 'subject':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('subject_id'))
]
elif groupby == 'priority':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('priority'))
]
elif groupby == 'state':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('state'))
]
# content according to pager and archive selected
values.update({
'created': ctr,
'tickets':tickets,
'grouped_tickets':grouped_tickets,
'page_name':'soporte',
'default_url':'/my/soporte',
'support_count':support_count,
'pager':pager,
'searchbar_sortings':searchbar_sortings,
'search_in':search_in,
'sortby':sortby,
'groupby':groupby,
'searchbar_inputs':searchbar_inputs,
'searchbar_groupby':searchbar_groupby,
'searchbar_filters':OrderedDict(sorted(searchbar_filters.items())),
'filterby':filterby,
'description': "Obtenga ayuda de TI",
'avatar_icon':'/helpdesk_morsa/static/src/img/support.svg'
})
return request.render("helpdesk_morsa.portal_my_support",values)
@http.route(['/my/erp', '/my/erp/page/<int:page>'],type='http',auth="user",website=True)
def portal_my_erp(self,ctr='show',page=1,sortby=None,filterby=None,search=None,search_in='all',groupby='create_by',**kw):
values = self._prepare_portal_layout_values()
HelpdeskTicket = request.env['helpdesk.ticket'].sudo()
#domain = self._prepare_portal_layout_erp_asistence()
searchbar_sortings = {
'create_date': {
'label': _('Newest'),
'order': 'create_date desc'
},
'name': {
'label': _('Name'),
'order': 'name'
},
}
searchbar_inputs = {
'all': {
'input': 'all',
'label': _('Search in All')
},
}
searchbar_groupby = {
'create_by': {
'input': 'create_by',
'label': _('Created By')
},
'ticket_type': {
'input': 'ticket_type',
'label': _('Ticket Type')
},
'status': {
'input': 'status',
'label': _('Status')
},
'customer': {
'input': 'customer',
'label': _('Customer')
},
'category': {
'input': 'category',
'label': _('Category')
},
'subcategory': {
'input': 'subcategory',
'label': _('Sub Category')
},
'subject': {
'input': 'subject',
'label': _('Subject')
},
'priority': {
'input': 'priority',
'label': _('Priority')
},
'state': {
'input': 'state',
'label': _('Reply Status')
},
}
today = fields.Date.today()
quarter_start, quarter_end = date_utils.get_quarter(today)
last_week = today + relativedelta(weeks=-1)
last_month = today + relativedelta(months=-1)
last_year = today + relativedelta(years=-1)
searchbar_filters = {
'all': {
'label': _('All'),
'domain': []
},
'today': {
'label': _('Today'),
'domain': [("create_date", "=", today)]
},
'week': {
'label':
_('This week'),
'domain':
[('create_date', '>=', date_utils.start_of(today, "week")),
('create_date', '<=', date_utils.end_of(today, 'week'))]
},
'month': {
'label':
_('This month'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'month')),
('create_date', '<=', date_utils.end_of(today, 'month'))]
},
'year': {
'label':
_('This year'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'year')),
('create_date', '<=', date_utils.end_of(today, 'year'))]
},
'quarter': {
'label':
_('This Quarter'),
'domain': [('create_date', '>=', quarter_start),
('create_date', '<=', quarter_end)]
},
'last_week': {
'label':
_('Last week'),
'domain':
[('create_date', '>=', date_utils.start_of(last_week, "week")),
('create_date', '<=', date_utils.end_of(last_week, 'week'))]
},
'last_month': {
'label':
_('Last month'),
'domain':
[('create_date', '>=',
date_utils.start_of(last_month, 'month')),
('create_date', '<=', date_utils.end_of(last_month, 'month'))]
},
'last_year': {
'label':
_('Last year'),
'domain':
[('create_date', '>=', date_utils.start_of(last_year, 'year')),
('create_date', '<=', date_utils.end_of(last_year, 'year'))]
},
}
# default sort by value
if not sortby:
sortby = 'create_date'
order = searchbar_sortings[sortby]['order']
# default filter by value
if not filterby:
filterby = 'all'
domain = AND([searchbar_filters[filterby]['domain']])
if search and search_in:
domain = AND([domain, [('name', 'ilike', search)]])
ticket_domain = self.prepare_portal_layout_erp_asistence()
if request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'user':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'leader':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'manager':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('sh_user_ids', '=', False))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('user_id', '=', False))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
ticket_domain.append(('team_head', '=', False))
else:
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
stage_close = request.env.ref('sh_all_in_one_helpdesk.close_stage').id
stage_done = request.env.ref('sh_all_in_one_helpdesk.done_stage').id
stage_cancel = request.env.ref('sh_all_in_one_helpdesk.cancel_stage').id
ticket_domain.append(('stage_id.id','not in',[stage_close,stage_done,stage_cancel]))
domain = AND([domain, ticket_domain])
# count for pager
erp_count = len(HelpdeskTicket.search(domain).filtered(lambda h: h.team_id == request.env.ref('helpdesk_morsa.erp_asistense').id))
# pager
pager = portal_pager(url="/my/erp",url_args={'sortby': sortby,'search_in': search_in,'search': search,'filterby': filterby},total=erp_count,page=page,step=self._items_per_page)
if groupby == 'create_by':
order = "create_uid, %s" % order
elif groupby == 'ticket_type':
order = "ticket_type, %s" % order
elif groupby == 'status':
order = "stage_id, %s" % order
elif groupby == 'customer':
order = "partner_id, %s" % order
elif groupby == 'category':
order = "category_id, %s" % order
elif groupby == 'subcategory':
order = "sub_category_id, %s" % order
elif groupby == 'subject':
order = "subject_id, %s" % order
elif groupby == 'priority':
order = "priority, %s" % order
elif groupby == 'state':
order = 'state,%s' % order
tickets = HelpdeskTicket.search(domain,order=order,limit=self._items_per_page,offset=pager['offset'])
request.session['my_tickets_history'] = tickets.ids[:100]
if groupby == 'create_by':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('create_uid'))
]
elif groupby == 'ticket_type':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('ticket_type'))
]
elif groupby == 'status':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('stage_id'))
]
elif groupby == 'customer':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('partner_id'))
]
elif groupby == 'category':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('category_id'))
]
elif groupby == 'subcategory':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('sub_category_id'))
]
elif groupby == 'subject':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('subject_id'))
]
elif groupby == 'priority':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('priority'))
]
elif groupby == 'state':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('state'))
]
# content according to pager and archive selected
values.update({
'created':ctr,
'tickets':tickets,
'grouped_tickets':grouped_tickets,
'page_name':'erp',
'default_url':'/my/erp',
'erp_count':erp_count,
'pager':pager,
'searchbar_sortings':searchbar_sortings,
'search_in':search_in,
'sortby':sortby,
'groupby':groupby,
'searchbar_inputs':searchbar_inputs,
'searchbar_groupby':searchbar_groupby,
'searchbar_filters':OrderedDict(sorted(searchbar_filters.items())),
'filterby':filterby,
'avatar_icon':'/helpdesk_morsa/static/src/img/erp.svg'
})
return request.render("helpdesk_morsa.portal_my_erp",values)
@http.route(['/my/911', '/my/911/page/<int:page>'],type='http',auth="user",website=True)
def portal_my_911(self,ctr='show',page=1,sortby=None,filterby=None,search=None,search_in='all',groupby='create_by',**kw):
values = self._prepare_portal_layout_values()
HelpdeskTicket = request.env['helpdesk.ticket'].sudo()
#domain = self.prepare_portal_layout_911()
searchbar_sortings = {
'create_date': {
'label': _('Newest'),
'order': 'create_date desc'
},
'name': {
'label': _('Name'),
'order': 'name'
},
}
searchbar_inputs = {
'all': {
'input': 'all',
'label': _('Search in All')
},
}
searchbar_groupby = {
'create_by': {
'input': 'create_by',
'label': _('Created By')
},
'ticket_type': {
'input': 'ticket_type',
'label': _('Ticket Type')
},
'status': {
'input': 'status',
'label': _('Status')
},
'customer': {
'input': 'customer',
'label': _('Customer')
},
'category': {
'input': 'category',
'label': _('Category')
},
'subcategory': {
'input': 'subcategory',
'label': _('Sub Category')
},
'subject': {
'input': 'subject',
'label': _('Subject')
},
'priority': {
'input': 'priority',
'label': _('Priority')
},
'state': {
'input': 'state',
'label': _('Reply Status')
},
}
#domain = self._prepare_portal_layout_911()
today = fields.Date.today()
quarter_start, quarter_end = date_utils.get_quarter(today)
last_week = today + relativedelta(weeks=-1)
last_month = today + relativedelta(months=-1)
last_year = today + relativedelta(years=-1)
searchbar_filters = {
'all': {
'label': _('All'),
'domain': []
},
'today': {
'label': _('Today'),
'domain': [("create_date", "=", today)]
},
'week': {
'label':
_('This week'),
'domain':
[('create_date', '>=', date_utils.start_of(today, "week")),
('create_date', '<=', date_utils.end_of(today, 'week'))]
},
'month': {
'label':
_('This month'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'month')),
('create_date', '<=', date_utils.end_of(today, 'month'))]
},
'year': {
'label':
_('This year'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'year')),
('create_date', '<=', date_utils.end_of(today, 'year'))]
},
'quarter': {
'label':
_('This Quarter'),
'domain': [('create_date', '>=', quarter_start),
('create_date', '<=', quarter_end)]
},
'last_week': {
'label':
_('Last week'),
'domain':
[('create_date', '>=', date_utils.start_of(last_week, "week")),
('create_date', '<=', date_utils.end_of(last_week, 'week'))]
},
'last_month': {
'label':
_('Last month'),
'domain':
[('create_date', '>=',
date_utils.start_of(last_month, 'month')),
('create_date', '<=', date_utils.end_of(last_month, 'month'))]
},
'last_year': {
'label':
_('Last year'),
'domain':
[('create_date', '>=', date_utils.start_of(last_year, 'year')),
('create_date', '<=', date_utils.end_of(last_year, 'year'))]
},
}
# default sort by value
if not sortby:
sortby = 'create_date'
order = searchbar_sortings[sortby]['order']
# default filter by value
if not filterby:
filterby = 'all'
domain = AND([searchbar_filters[filterby]['domain']])
if search and search_in:
domain = AND([domain, [('name', 'ilike', search)]])
ticket_domain = self.prepare_portal_layout_911()
if request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'user':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'leader':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'manager':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('sh_user_ids', '=', False))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('user_id', '=', False))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
ticket_domain.append(('team_head', '=', False))
else:
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
stage_close = request.env.ref('sh_all_in_one_helpdesk.close_stage').id
stage_done = request.env.ref('sh_all_in_one_helpdesk.done_stage').id
stage_cancel = request.env.ref('sh_all_in_one_helpdesk.cancel_stage').id
ticket_domain.append(('stage_id.id','not in',[stage_close,stage_done,stage_cancel]))
domain = AND([domain, ticket_domain])
# count for pager
helpdesk = HelpdeskTicket.sudo().search(domain)
ti_count = len(helpdesk)
@http.route('/my/ti',type='http',auth="user",website=True)
def prepare_portal_ti(self,**kw):
values = self._prepare_home_portal_values()
return request.render("helpdesk_morsa.portal_my_ti",values)
# pager
pager = portal_pager(url="/my/911",url_args={'sortby': sortby,'search_in': search_in,'search': search,'filterby': filterby},total=ti_count,page=page,step=self._items_per_page)
if groupby == 'create_by':
order = "create_uid, %s" % order
elif groupby == 'ticket_type':
order = "ticket_type, %s" % order
elif groupby == 'status':
order = "stage_id, %s" % order
elif groupby == 'customer':
order = "partner_id, %s" % order
elif groupby == 'category':
order = "category_id, %s" % order
elif groupby == 'subcategory':
order = "sub_category_id, %s" % order
elif groupby == 'subject':
order = "subject_id, %s" % order
elif groupby == 'priority':
order = "priority, %s" % order
elif groupby == 'state':
order = 'state,%s' % order
tickets = HelpdeskTicket.search(domain,order=order,limit=self._items_per_page,offset=pager['offset'])
request.session['my_tickets_history'] = tickets.ids[:100]
if groupby == 'create_by':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('create_uid'))
]
elif groupby == 'ticket_type':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('ticket_type'))
]
elif groupby == 'status':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('stage_id'))
]
elif groupby == 'customer':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('partner_id'))
]
elif groupby == 'category':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('category_id'))
]
elif groupby == 'subcategory':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('sub_category_id'))
]
elif groupby == 'subject':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('subject_id'))
]
elif groupby == 'priority':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('priority'))
]
elif groupby == 'state':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('state'))
]
# content according to pager and archive selected
values.update({
'created':ctr,
'tickets':tickets,
'grouped_tickets':grouped_tickets,
'page_name':'ti',
'default_url':'/my/911',
'ti_count':ti_count,
'pager':pager,
'searchbar_sortings':searchbar_sortings,
'search_in':search_in,
'sortby':sortby,
'groupby':groupby,
'searchbar_inputs':searchbar_inputs,
'searchbar_groupby':searchbar_groupby,
'searchbar_filters':OrderedDict(sorted(searchbar_filters.items())),
'filterby':filterby,
'description': "Emergencias",
'avatar_icon':'/helpdesk_morsa/static/src/img/emergency.svg'
})
return request.render("helpdesk_morsa.portal_my_911",values)
@http.route('/selected-partner-data',type="http",auth="public",csrf=False)
def selected_partner_data(self, **kw):
......@@ -964,412 +51,11 @@ class PortalHelpdeskMorsa(PortalHelpdesk):
return json.dumps(dic)
@http.route('/portal-create-ticket-soporte', type='http', auth='public',csrf=False)
def portal_create_ticket_support(self, **kw):
try:
_logger.info(kw)
login_user = request.env.user
if login_user and login_user.login != 'public':
partner_id = False
if kw.get('partner_id') and kw.get('partner_id') != '':
partner_id = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1)
else:
partner_id = request.env['res.partner'].sudo().search(
[('email', '=', kw.get('portal_email'))], limit=1)
if not partner_id:
return json.dumps({"resp":"Error","message":"Colaborador no encontrado, favor de verificar que haya agregado uno"})
if partner_id:
unvalued_tickets = len(
request.env['helpdesk.ticket'].sudo().search([
('stage_id','=',request.env.ref('sh_all_in_one_helpdesk.done_stage').id),
('priority_new','=',False)])
)
if unvalued_tickets >= 3:
return json.dumps({"resp":"Error","message":"Tienes demasiados tickets sin evaluar, favor de evaluarlos"})
ticket_dic = {
'partner_id': partner_id.id,
'ticket_from_portal': True
}
if kw.get('portal_phone'):
partner_id.update({'phone': kw.get('portal_phone')})
ticket_dic.update({
'mobile_no':kw.get('portal_phone')
})
if kw.get('portal_contact_name'):
ticket_dic.update({
'person_name':
kw.get('portal_contact_name'),
})
if kw.get('portal_email'):
ticket_dic.update({
'email': kw.get('portal_email'),
})
team_id = request.env['helpdesk.team'].sudo().browse(request.env.ref('helpdesk_morsa.techinnical_support').id)
if team_id:
ticket_dic.update({
'team_id': team_id.id,
'team_head': team_id.team_head.id,
})
ticket_dic.update({'description':False})
ticket_id = request.env['helpdesk.ticket'].sudo().create(
ticket_dic)
if 'portal_file' in request.params:
attached_files = request.httprequest.files.getlist('portal_file')
attachment_ids = []
for attachment in attached_files:
result = base64.b64encode(attachment.read())
attachment_id = request.env['ir.attachment'].sudo(
).create({
'name': attachment.filename,
'res_model': 'helpdesk.ticket',
'res_id': ticket_id.id,
'display_name': attachment.filename,
'datas': result,
})
attachment_ids.append(attachment_id.id)
ticket_id.attachment_ids = [(6, 0, attachment_ids)]
return request.redirect("/my/soporte?ctr=False")
except Exception as e:
_logger.exception('Something went wrong %s',str(e))
@http.route('/portal-create-ticket-erp',type='http',auth='public',csrf=False)
def portal_create_ticket_erp(self, **kw):
try:
login_user = request.env.user
if login_user and login_user.login != 'public':
partner_id = False
if kw.get('partner_id') and kw.get('partner_id') != '':
partner_id = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1)
else:
partner_id = request.env['res.partner'].sudo().search(
[('email', '=', kw.get('portal_email'))], limit=1)
if not partner_id:
return json.dumps({"resp":"Error","message":"Colaborador no encontrado, favor de verificar que haya agregado uno existente"})
if partner_id:
unvalued_tickets = len(
request.env['helpdesk.ticket'].sudo().search([
('stage_id','=',request.env.ref('sh_all_in_one_helpdesk.done_stage').id),
('priority_new','=',False)])
)
if unvalued_tickets >= 3:
return json.dumps({"resp":"Error","message":"Tienes demasiados tickets sin evaluar, favor de evaluarlos"})
ticket_dic = {
'partner_id': partner_id.id,
'ticket_from_portal': True
}
if kw.get('portal_phone'):
partner_id.update({'phone': kw.get('portal_phone')})
ticket_dic.update({'mobile_no':kw.get('portal_phone')})
if kw.get('portal_contact_name'):
ticket_dic.update({
'person_name':
kw.get('portal_contact_name'),
})
if kw.get('portal_email'):
ticket_dic.update({
'email': kw.get('portal_email'),
})
team_id = request.env['helpdesk.team'].sudo().browse(request.env.ref('helpdesk_morsa.erp_asistense').id)
if team_id:
ticket_dic.update({
'team_id': team_id.id,
'team_head': team_id.team_head.id,
})
if kw.get('portal_erp_type'):
ticket_dic.update({
'erp_type':kw.get('portal_erp_type')
})
if kw.get('portal_erp_type') == 'soporte':
if kw.get('portal_sucursal') and kw.get('portal_sucursal') != 'sucursal':
portal_surcusal_id = request.env['warehouse.helpdesk'].sudo().browse(int(kw.get('portal_sucursal')))
if portal_surcusal_id:
ticket_dic.update({
'warehouse_id':portal_surcusal_id.id
})
if kw.get('portal_module') and kw.get('portal_module') != 'modulo':
portal_module_id = request.env['erp.modules'].sudo().browse(int(kw.get('portal_module')))
if portal_module_id:
ticket_dic.update({
'erp_id':portal_module_id.id
})
else:
self.raise_error("Es necesario el apartado de modulo para crear su ticket")
elif kw.get('portal_erp_type') == 'mejora':
if 'portal_file' not in request.params and 'portal_file_mejora' not in request.params:
return json.dumps({"resp":"Error","message":"Es necesario agregar la archivos"})
else:
return json.dumps({"resp":"Error","message":"El tipo de ticket no se encuentra dentro de los valores"})
else:
return json.dumps({"resp":"Error","message":"No existe tipo de ticket"})
ticket_id = request.env['helpdesk.ticket'].sudo().create(
ticket_dic)
if 'portal_file' in request.params :
attached_files = request.httprequest.files.getlist('portal_file')
attachment_ids = []
for attachment in attached_files:
result = base64.b64encode(attachment.read())
attachment_id = request.env['ir.attachment'].sudo(
).create({
'name': attachment.filename,
'res_model': 'helpdesk.ticket',
'res_id': ticket_id.id,
'display_name': attachment.filename,
'datas': result,
})
attachment_ids.append(attachment_id.id)
ticket_id.attachment_ids = [(6, 0, attachment_ids)]
if 'portal_file_mejora' in request.params :
attached_files = request.httprequest.files.getlist('portal_file_mejora')
attachment_ids = []
for attachment in attached_files:
result = base64.b64encode(attachment.read())
attachment_id = request.env['ir.attachment'].sudo(
).create({
'name': attachment.filename,
'res_model': 'helpdesk.ticket',
'res_id': ticket_id.id,
'display_name': attachment.filename,
'datas': result,
})
attachment_ids.append(attachment_id.id)
ticket_id.attachment_ids = [(6, 0, attachment_ids)]
return request.redirect("/my/erp?ctr=False")
except Exception as e:
_logger.exception('Something went wrong %s',str(e))
@http.route('/portal-create-ticket-911',type='http',auth='public',csrf=False)
def portal_create_ticket_911(self, **kw):
try:
login_user = request.env.user
if login_user and login_user.login != 'public':
partner_id = False
if kw.get('partner_id') and kw.get('partner_id') != '':
partner_id = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1)
else:
partner_id = request.env['res.partner'].sudo().search(
[('email', '=', kw.get('portal_email'))], limit=1)
if not partner_id:
return json.dumps({"resp":"Error","message":"No hay contacto"})
if partner_id:
unvalued_tickets = len(
request.env['helpdesk.ticket'].sudo().search([
('stage_id','=',request.env.ref('sh_all_in_one_helpdesk.done_stage').id),
('priority_new','=',False)])
)
if unvalued_tickets >= 3:
return json.dumps({"resp":"Error","message":"Tienes demasiados tickets sin evaluar, favor de evaluarlos"})
ticket_dic = {
'partner_id': partner_id.id,
'ticket_from_portal': True
}
team_id = request.env['helpdesk.team'].sudo().browse(request.env.ref('helpdesk_morsa.ti_emergency').id)
if team_id:
ticket_dic.update({
'team_id': team_id.id,
'team_head': team_id.team_head.id,
})
if kw.get('portal_incidence') and kw.get('portal_incidence') != "incidence":
ticket_dic.update({
'incidence_type':kw.get('portal_incidence')
})
if kw.get('portal_phone'):
partner_id.update({'phone': kw.get('portal_phone')})
ticket_dic.update({
'mobile_no':kw.get('portal_phone')
})
if kw.get('portal_contact_name'):
ticket_dic.update({
'person_name':
kw.get('portal_contact_name'),
})
if kw.get('portal_email'):
ticket_dic.update({
'email': kw.get('portal_email'),
})
ticket_id = request.env['helpdesk.ticket'].sudo().create(
ticket_dic)
if 'portal_file' in request.params:
attached_files = request.httprequest.files.getlist(
'portal_file')
attachment_ids = []
for attachment in attached_files:
result = base64.b64encode(attachment.read())
attachment_id = request.env['ir.attachment'].sudo(
).create({
'name': attachment.filename,
'res_model': 'helpdesk.ticket',
'res_id': ticket_id.id,
'display_name': attachment.filename,
'datas': result,
})
attachment_ids.append(attachment_id.id)
ticket_id.attachment_ids = [(6, 0, attachment_ids)]
return request.redirect("/my/911?ctr=False")
except Exception as e:
_logger.exception('Something went wrong %s',str(e))
@http.route(['/my/soporte/<int:ticket_id>'],
type='http',
auth="public",
website=True)
def portal_my_ticket_detail_soporte(self,ticket_id,access_token=None,report_type=None,message=False,download=False,**kw):
try:
ticket_sudo = self._document_check_access('helpdesk.ticket', ticket_id, access_token=access_token)
except (AccessError, MissingError):
return request.redirect('/my')
if report_type in ('html', 'pdf', 'text'):
return self._show_report(model=ticket_sudo,report_type=report_type,report_ref='sh_all_in_one_helpdesk.action_portal_report_helpdesk_ticket',download=download)
if ticket_sudo:
if request.env.company.sh_receive_email_seeing_ticket:
body = _('Ticket visto por el cliente %s',ticket_sudo.partner_id.name)
_message_post_helper(
"helpdesk.ticket",
ticket_sudo.id,
body,
token=ticket_sudo.access_token,
message_type="notification",
subtype_xmlid="mail.mt_note",
partner_ids=ticket_sudo.user_id.sudo().partner_id.ids,
)
values = {
'token': access_token,
'soporte': ticket_sudo,
'message': message,
'bootstrap_formatting': True,
'partner_id': ticket_sudo.partner_id.id,
'report_type': 'html',
}
return request.render("helpdesk_morsa.portal_ticket_page_support",values)
@http.route(['/my/erp/<int:ticket_id>'],
type='http',
auth="public",
website=True)
def portal_my_ticket_detail_erp(self,
ticket_id,
access_token=None,
report_type=None,
message=False,
download=False,
**kw):
try:
ticket_sudo = self._document_check_access(
'helpdesk.ticket', ticket_id, access_token=access_token)
except (AccessError, MissingError):
return request.redirect('/my')
if report_type in ('html', 'pdf', 'text'):
return self._show_report(
model=ticket_sudo,
report_type=report_type,
report_ref=
'sh_all_in_one_helpdesk.action_portal_report_helpdesk_ticket',
download=download)
if ticket_sudo:
if request.env.company.sh_receive_email_seeing_ticket:
body = _('Ticket visto por el cliente %s',
ticket_sudo.partner_id.name)
_message_post_helper(
"helpdesk.ticket",
ticket_sudo.id,
body,
token=ticket_sudo.access_token,
message_type="notification",
subtype_xmlid="mail.mt_note",
partner_ids=ticket_sudo.user_id.sudo().partner_id.ids,
)
values = {
'token': access_token,
'asistencia': ticket_sudo,
'message': message,
'bootstrap_formatting': True,
'partner_id': ticket_sudo.partner_id.id,
'report_type': 'html',
}
return request.render("helpdesk_morsa.portal_ticket_page_erp",
values)
@http.route(['/my/911/<int:ticket_id>'],
type='http',
auth="public",
website=True)
def portal_my_ticket_detail_911(self,
ticket_id,
access_token=None,
report_type=None,
message=False,
download=False,
**kw):
try:
ticket_sudo = self._document_check_access(
'helpdesk.ticket', ticket_id, access_token=access_token)
except (AccessError, MissingError):
return request.redirect('/my')
if report_type in ('html', 'pdf', 'text'):
return self._show_report(
model=ticket_sudo,
report_type=report_type,
report_ref=
'sh_all_in_one_helpdesk.action_portal_report_helpdesk_ticket',
download=download)
if ticket_sudo:
if request.env.company.sh_receive_email_seeing_ticket:
body = _('Ticket visto por el cliente %s',
ticket_sudo.partner_id.name)
_message_post_helper(
"helpdesk.ticket",
ticket_sudo.id,
body,
token=ticket_sudo.access_token,
message_type="notification",
subtype_xmlid="mail.mt_note",
partner_ids=ticket_sudo.user_id.sudo().partner_id.ids,
)
values = {
'token': access_token,
'ti': ticket_sudo,
'message': message,
'bootstrap_formatting': True,
'partner_id': ticket_sudo.partner_id.id,
'report_type': 'html',
}
return request.render("helpdesk_morsa.portal_ticket_page_911",values)
@http.route(['/unvaluated/tickets'],type='http',auth="none",website=True,csrf=False)
......
from odoo import fields, http, _
from odoo.http import request
from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager
from odoo.tools import date_utils, groupby as groupbyelem
from odoo.osv.expression import AND
from dateutil.relativedelta import relativedelta
from operator import itemgetter
from collections import OrderedDict
from odoo.exceptions import AccessError, MissingError, UserError
from odoo.addons.portal.controllers.mail import _message_post_helper
from datetime import datetime, timedelta
import json
import base64
import werkzeug
import logging
_logger = logging.getLogger(__name__)
from odoo.addons.sh_all_in_one_helpdesk.controllers.portal import PortalHelpdesk
class PortalHelpdeskMorsaEmergency(PortalHelpdesk):
def _prepare_portal_layout_values(self):
values = super(PortalHelpdesk, self)._prepare_portal_layout_values()
stage_close = request.env.ref('sh_all_in_one_helpdesk.close_stage').id
stage_done = request.env.ref('sh_all_in_one_helpdesk.done_stage').id
stage_cancel = request.env.ref('sh_all_in_one_helpdesk.cancel_stage').id
ticket_domain = [('stage_id.id','not in',[stage_close,stage_done,stage_cancel])]
if request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'user':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'leader':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'manager':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('user_id', '=', False))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('sh_user_ids', '=', False))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
ticket_domain.append(('team_head', '=', False))
else:
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
new_domain_ti = AND([self.prepare_portal_layout_911(), ticket_domain])
ti_count = len(request.env['helpdesk.ticket'].sudo().search(new_domain_ti))
tickets = request.env['helpdesk.ticket'].sudo().search(ticket_domain)
values['ti_count'] = ti_count
values['tickets'] = tickets
return values
def prepare_portal_layout_911(self):
domain = [('team_id.id','=',request.env.ref('helpdesk_morsa.ti_emergency').id)]
return domain
@http.route(['/my/911', '/my/911/page/<int:page>'],type='http',auth="user",website=True)
def portal_my_911(self,ctr='show',page=1,sortby=None,filterby=None,search=None,search_in='all',groupby='create_by',**kw):
values = self._prepare_portal_layout_values()
HelpdeskTicket = request.env['helpdesk.ticket'].sudo()
#domain = self.prepare_portal_layout_911()
searchbar_sortings = {
'create_date': {
'label': _('Newest'),
'order': 'create_date desc'
},
'name': {
'label': _('Name'),
'order': 'name'
},
}
searchbar_inputs = {
'all': {
'input': 'all',
'label': _('Search in All')
},
}
searchbar_groupby = {
'create_by': {
'input': 'create_by',
'label': _('Created By')
},
'ticket_type': {
'input': 'ticket_type',
'label': _('Ticket Type')
},
'status': {
'input': 'status',
'label': _('Status')
},
'customer': {
'input': 'customer',
'label': _('Customer')
},
'category': {
'input': 'category',
'label': _('Category')
},
'subcategory': {
'input': 'subcategory',
'label': _('Sub Category')
},
'subject': {
'input': 'subject',
'label': _('Subject')
},
'priority': {
'input': 'priority',
'label': _('Priority')
},
'state': {
'input': 'state',
'label': _('Reply Status')
},
}
#domain = self._prepare_portal_layout_911()
today = fields.Date.today()
quarter_start, quarter_end = date_utils.get_quarter(today)
last_week = today + relativedelta(weeks=-1)
last_month = today + relativedelta(months=-1)
last_year = today + relativedelta(years=-1)
searchbar_filters = {
'all': {
'label': _('All'),
'domain': []
},
'today': {
'label': _('Today'),
'domain': [("create_date", "=", today)]
},
'week': {
'label':
_('This week'),
'domain':
[('create_date', '>=', date_utils.start_of(today, "week")),
('create_date', '<=', date_utils.end_of(today, 'week'))]
},
'month': {
'label':
_('This month'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'month')),
('create_date', '<=', date_utils.end_of(today, 'month'))]
},
'year': {
'label':
_('This year'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'year')),
('create_date', '<=', date_utils.end_of(today, 'year'))]
},
'quarter': {
'label':
_('This Quarter'),
'domain': [('create_date', '>=', quarter_start),
('create_date', '<=', quarter_end)]
},
'last_week': {
'label':
_('Last week'),
'domain':
[('create_date', '>=', date_utils.start_of(last_week, "week")),
('create_date', '<=', date_utils.end_of(last_week, 'week'))]
},
'last_month': {
'label':
_('Last month'),
'domain':
[('create_date', '>=',
date_utils.start_of(last_month, 'month')),
('create_date', '<=', date_utils.end_of(last_month, 'month'))]
},
'last_year': {
'label':
_('Last year'),
'domain':
[('create_date', '>=', date_utils.start_of(last_year, 'year')),
('create_date', '<=', date_utils.end_of(last_year, 'year'))]
},
}
# default sort by value
if not sortby:
sortby = 'create_date'
order = searchbar_sortings[sortby]['order']
# default filter by value
if not filterby:
filterby = 'all'
domain = AND([searchbar_filters[filterby]['domain']])
if search and search_in:
domain = AND([domain, [('name', 'ilike', search)]])
ticket_domain = self.prepare_portal_layout_911()
if request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'user':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'leader':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'manager':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('sh_user_ids', '=', False))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('user_id', '=', False))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
ticket_domain.append(('team_head', '=', False))
else:
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
stage_close = request.env.ref('sh_all_in_one_helpdesk.close_stage').id
stage_done = request.env.ref('sh_all_in_one_helpdesk.done_stage').id
stage_cancel = request.env.ref('sh_all_in_one_helpdesk.cancel_stage').id
ticket_domain.append(('stage_id.id','not in',[stage_close,stage_done,stage_cancel]))
domain = AND([domain, ticket_domain])
# count for pager
helpdesk = HelpdeskTicket.sudo().search(domain)
ti_count = len(helpdesk)
# pager
pager = portal_pager(url="/my/911",url_args={'sortby': sortby,'search_in': search_in,'search': search,'filterby': filterby},total=ti_count,page=page,step=self._items_per_page)
if groupby == 'create_by':
order = "create_uid, %s" % order
elif groupby == 'ticket_type':
order = "ticket_type, %s" % order
elif groupby == 'status':
order = "stage_id, %s" % order
elif groupby == 'customer':
order = "partner_id, %s" % order
elif groupby == 'category':
order = "category_id, %s" % order
elif groupby == 'subcategory':
order = "sub_category_id, %s" % order
elif groupby == 'subject':
order = "subject_id, %s" % order
elif groupby == 'priority':
order = "priority, %s" % order
elif groupby == 'state':
order = 'state,%s' % order
tickets = HelpdeskTicket.search(domain,order=order,limit=self._items_per_page,offset=pager['offset'])
request.session['my_tickets_history'] = tickets.ids[:100]
if groupby == 'create_by':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('create_uid'))
]
elif groupby == 'ticket_type':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('ticket_type'))
]
elif groupby == 'status':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('stage_id'))
]
elif groupby == 'customer':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('partner_id'))
]
elif groupby == 'category':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('category_id'))
]
elif groupby == 'subcategory':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('sub_category_id'))
]
elif groupby == 'subject':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('subject_id'))
]
elif groupby == 'priority':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('priority'))
]
elif groupby == 'state':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('state'))
]
# content according to pager and archive selected
values.update({
'created':ctr,
'tickets':tickets,
'grouped_tickets':grouped_tickets,
'page_name':'ti',
'default_url':'/my/911',
'ti_count':ti_count,
'pager':pager,
'searchbar_sortings':searchbar_sortings,
'search_in':search_in,
'sortby':sortby,
'groupby':groupby,
'searchbar_inputs':searchbar_inputs,
'searchbar_groupby':searchbar_groupby,
'searchbar_filters':OrderedDict(sorted(searchbar_filters.items())),
'filterby':filterby,
'description': "Emergencias",
})
return request.render("helpdesk_morsa.portal_my_911",values)
@http.route('/portal-create-ticket-911',type='http',auth='public',csrf=False)
def portal_create_ticket_911(self, **kw):
try:
login_user = request.env.user
if login_user and login_user.login != 'public':
partner_id = False
if kw.get('partner_id') and kw.get('partner_id') != '':
partner_id = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1)
else:
partner_id = request.env['res.partner'].sudo().search(
[('email', '=', kw.get('portal_email'))], limit=1)
if not partner_id:
return json.dumps({"resp":"Error","message":"No hay contacto"})
if partner_id:
unvalued_tickets = len(
request.env['helpdesk.ticket'].sudo().search([
('stage_id','=',request.env.ref('sh_all_in_one_helpdesk.done_stage').id),
('priority_new','=',False)])
)
if unvalued_tickets >= 3:
return json.dumps({"resp":"Error","message":"Tienes demasiados tickets sin evaluar, favor de evaluarlos"})
ticket_dic = {
'partner_id': partner_id.id,
'ticket_from_portal': True
}
team_id = request.env['helpdesk.team'].sudo().browse(request.env.ref('helpdesk_morsa.ti_emergency').id)
if team_id:
ticket_dic.update({
'team_id': team_id.id,
'team_head': team_id.team_head.id,
})
if kw.get('portal_incidence') and kw.get('portal_incidence') != "incidence":
ticket_dic.update({
'incidence_type':kw.get('portal_incidence')
})
if kw.get('portal_phone'):
partner_id.update({'phone': kw.get('portal_phone')})
ticket_dic.update({
'mobile_no':kw.get('portal_phone')
})
if kw.get('portal_contact_name'):
ticket_dic.update({
'person_name':
kw.get('portal_contact_name'),
})
if kw.get('portal_email'):
ticket_dic.update({
'email': kw.get('portal_email'),
})
ticket_id = request.env['helpdesk.ticket'].sudo().create(
ticket_dic)
if 'portal_file' in request.params:
attached_files = request.httprequest.files.getlist(
'portal_file')
attachment_ids = []
for attachment in attached_files:
result = base64.b64encode(attachment.read())
attachment_id = request.env['ir.attachment'].sudo(
).create({
'name': attachment.filename,
'res_model': 'helpdesk.ticket',
'res_id': ticket_id.id,
'display_name': attachment.filename,
'datas': result,
})
attachment_ids.append(attachment_id.id)
ticket_id.attachment_ids = [(6, 0, attachment_ids)]
return request.redirect("/my/911?ctr=False")
except Exception as e:
_logger.exception('Something went wrong %s',str(e))
@http.route(['/my/911/<int:ticket_id>'],type='http',auth="public",website=True)
def portal_my_ticket_detail_911(self,ticket_id,access_token=None,report_type=None,message=False,download=False,**kw):
try:
ticket_sudo = self._document_check_access(
'helpdesk.ticket', ticket_id, access_token=access_token)
except (AccessError, MissingError):
return request.redirect('/my')
if report_type in ('html', 'pdf', 'text'):
return self._show_report(
model=ticket_sudo,
report_type=report_type,
report_ref=
'sh_all_in_one_helpdesk.action_portal_report_helpdesk_ticket',
download=download)
if ticket_sudo:
if request.env.company.sh_receive_email_seeing_ticket:
body = _('Ticket visto por el cliente %s',
ticket_sudo.partner_id.name)
_message_post_helper(
"helpdesk.ticket",
ticket_sudo.id,
body,
token=ticket_sudo.access_token,
message_type="notification",
subtype_xmlid="mail.mt_note",
partner_ids=ticket_sudo.user_id.sudo().partner_id.ids,
)
values = {
'token': access_token,
'ti': ticket_sudo,
'message': message,
'bootstrap_formatting': True,
'partner_id': ticket_sudo.partner_id.id,
'report_type': 'html',
}
return request.render("helpdesk_morsa.portal_ticket_page_911",values)
from odoo import fields, http, _
from odoo.http import request
from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager
from odoo.tools import date_utils, groupby as groupbyelem
from odoo.osv.expression import AND
from dateutil.relativedelta import relativedelta
from operator import itemgetter
from collections import OrderedDict
from odoo.exceptions import AccessError, MissingError, UserError
from odoo.addons.portal.controllers.mail import _message_post_helper
from datetime import datetime, timedelta
import json
import base64
import werkzeug
import logging
_logger = logging.getLogger(__name__)
from odoo.addons.sh_all_in_one_helpdesk.controllers.portal import PortalHelpdesk
class PortalHelpdeskMorsaErp(PortalHelpdesk):
def _prepare_portal_layout_values(self):
values = super(PortalHelpdesk, self)._prepare_portal_layout_values()
stage_close = request.env.ref('sh_all_in_one_helpdesk.close_stage').id
stage_done = request.env.ref('sh_all_in_one_helpdesk.done_stage').id
stage_cancel = request.env.ref('sh_all_in_one_helpdesk.cancel_stage').id
ticket_domain = [('stage_id.id','not in',[stage_close,stage_done,stage_cancel])]
if request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'user':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'leader':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'manager':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('user_id', '=', False))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('sh_user_ids', '=', False))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
ticket_domain.append(('team_head', '=', False))
else:
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
new_domain_erp = AND([self.prepare_portal_layout_erp_asistence(), ticket_domain])
erp_count = len(request.env['helpdesk.ticket'].sudo().search(new_domain_erp))
tickets = request.env['helpdesk.ticket'].sudo().search(ticket_domain)
values['tickets'] = tickets
values['erp_count'] = erp_count
return values
def prepare_portal_layout_erp_asistence(self):
domain = [('team_id.id','=',request.env.ref('helpdesk_morsa.erp_asistense').id)]
return domain
@http.route(['/my/erp', '/my/erp/page/<int:page>'],type='http',auth="user",website=True)
def portal_my_erp(self,ctr='show',page=1,sortby=None,filterby=None,search=None,search_in='all',groupby='create_by',**kw):
values = self._prepare_portal_layout_values()
HelpdeskTicket = request.env['helpdesk.ticket'].sudo()
#domain = self._prepare_portal_layout_erp_asistence()
searchbar_sortings = {
'create_date': {
'label': _('Newest'),
'order': 'create_date desc'
},
'name': {
'label': _('Name'),
'order': 'name'
},
}
searchbar_inputs = {
'all': {
'input': 'all',
'label': _('Search in All')
},
}
searchbar_groupby = {
'create_by': {
'input': 'create_by',
'label': _('Created By')
},
'ticket_type': {
'input': 'ticket_type',
'label': _('Ticket Type')
},
'status': {
'input': 'status',
'label': _('Status')
},
'customer': {
'input': 'customer',
'label': _('Customer')
},
'category': {
'input': 'category',
'label': _('Category')
},
'subcategory': {
'input': 'subcategory',
'label': _('Sub Category')
},
'subject': {
'input': 'subject',
'label': _('Subject')
},
'priority': {
'input': 'priority',
'label': _('Priority')
},
'state': {
'input': 'state',
'label': _('Reply Status')
},
}
today = fields.Date.today()
quarter_start, quarter_end = date_utils.get_quarter(today)
last_week = today + relativedelta(weeks=-1)
last_month = today + relativedelta(months=-1)
last_year = today + relativedelta(years=-1)
searchbar_filters = {
'all': {
'label': _('All'),
'domain': []
},
'today': {
'label': _('Today'),
'domain': [("create_date", "=", today)]
},
'week': {
'label':
_('This week'),
'domain':
[('create_date', '>=', date_utils.start_of(today, "week")),
('create_date', '<=', date_utils.end_of(today, 'week'))]
},
'month': {
'label':
_('This month'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'month')),
('create_date', '<=', date_utils.end_of(today, 'month'))]
},
'year': {
'label':
_('This year'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'year')),
('create_date', '<=', date_utils.end_of(today, 'year'))]
},
'quarter': {
'label':
_('This Quarter'),
'domain': [('create_date', '>=', quarter_start),
('create_date', '<=', quarter_end)]
},
'last_week': {
'label':
_('Last week'),
'domain':
[('create_date', '>=', date_utils.start_of(last_week, "week")),
('create_date', '<=', date_utils.end_of(last_week, 'week'))]
},
'last_month': {
'label':
_('Last month'),
'domain':
[('create_date', '>=',
date_utils.start_of(last_month, 'month')),
('create_date', '<=', date_utils.end_of(last_month, 'month'))]
},
'last_year': {
'label':
_('Last year'),
'domain':
[('create_date', '>=', date_utils.start_of(last_year, 'year')),
('create_date', '<=', date_utils.end_of(last_year, 'year'))]
},
}
# default sort by value
if not sortby:
sortby = 'create_date'
order = searchbar_sortings[sortby]['order']
# default filter by value
if not filterby:
filterby = 'all'
domain = AND([searchbar_filters[filterby]['domain']])
if search and search_in:
domain = AND([domain, [('name', 'ilike', search)]])
ticket_domain = self.prepare_portal_layout_erp_asistence()
if request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'user':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'leader':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'manager':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('sh_user_ids', '=', False))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('user_id', '=', False))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
ticket_domain.append(('team_head', '=', False))
else:
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
stage_close = request.env.ref('sh_all_in_one_helpdesk.close_stage').id
stage_done = request.env.ref('sh_all_in_one_helpdesk.done_stage').id
stage_cancel = request.env.ref('sh_all_in_one_helpdesk.cancel_stage').id
ticket_domain.append(('stage_id.id','not in',[stage_close,stage_done,stage_cancel]))
domain = AND([domain, ticket_domain])
# count for pager
erp_count = len(HelpdeskTicket.search(domain).filtered(lambda h: h.team_id == request.env.ref('helpdesk_morsa.erp_asistense').id))
# pager
pager = portal_pager(url="/my/erp",url_args={'sortby': sortby,'search_in': search_in,'search': search,'filterby': filterby},total=erp_count,page=page,step=self._items_per_page)
if groupby == 'create_by':
order = "create_uid, %s" % order
elif groupby == 'ticket_type':
order = "ticket_type, %s" % order
elif groupby == 'status':
order = "stage_id, %s" % order
elif groupby == 'customer':
order = "partner_id, %s" % order
elif groupby == 'category':
order = "category_id, %s" % order
elif groupby == 'subcategory':
order = "sub_category_id, %s" % order
elif groupby == 'subject':
order = "subject_id, %s" % order
elif groupby == 'priority':
order = "priority, %s" % order
elif groupby == 'state':
order = 'state,%s' % order
tickets = HelpdeskTicket.search(domain,order=order,limit=self._items_per_page,offset=pager['offset'])
request.session['my_tickets_history'] = tickets.ids[:100]
if groupby == 'create_by':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('create_uid'))
]
elif groupby == 'ticket_type':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('ticket_type'))
]
elif groupby == 'status':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('stage_id'))
]
elif groupby == 'customer':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('partner_id'))
]
elif groupby == 'category':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('category_id'))
]
elif groupby == 'subcategory':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('sub_category_id'))
]
elif groupby == 'subject':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('subject_id'))
]
elif groupby == 'priority':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('priority'))
]
elif groupby == 'state':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('state'))
]
# content according to pager and archive selected
values.update({
'created':ctr,
'tickets':tickets,
'grouped_tickets':grouped_tickets,
'page_name':'erp',
'default_url':'/my/erp',
'erp_count':erp_count,
'pager':pager,
'searchbar_sortings':searchbar_sortings,
'search_in':search_in,
'sortby':sortby,
'groupby':groupby,
'searchbar_inputs':searchbar_inputs,
'searchbar_groupby':searchbar_groupby,
'searchbar_filters':OrderedDict(sorted(searchbar_filters.items())),
'filterby':filterby,
})
return request.render("helpdesk_morsa.portal_my_erp",values)
@http.route('/portal-create-ticket-erp',type='http',auth='public',csrf=False)
def portal_create_ticket_erp(self, **kw):
try:
login_user = request.env.user
if login_user and login_user.login != 'public':
partner_id = False
if kw.get('partner_id') and kw.get('partner_id') != '':
partner_id = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1)
else:
partner_id = request.env['res.partner'].sudo().search(
[('email', '=', kw.get('portal_email'))], limit=1)
if not partner_id:
return json.dumps({"resp":"Error","message":"Colaborador no encontrado, favor de verificar que haya agregado uno existente"})
if partner_id:
unvalued_tickets = len(
request.env['helpdesk.ticket'].sudo().search([
('stage_id','=',request.env.ref('sh_all_in_one_helpdesk.done_stage').id),
('priority_new','=',False)])
)
if unvalued_tickets >= 3:
return json.dumps({"resp":"Error","message":"Tienes demasiados tickets sin evaluar, favor de evaluarlos"})
ticket_dic = {
'partner_id': partner_id.id,
'ticket_from_portal': True
}
if kw.get('portal_phone'):
partner_id.update({'phone': kw.get('portal_phone')})
ticket_dic.update({'mobile_no':kw.get('portal_phone')})
if kw.get('portal_contact_name'):
ticket_dic.update({
'person_name':
kw.get('portal_contact_name'),
})
if kw.get('portal_email'):
ticket_dic.update({
'email': kw.get('portal_email'),
})
team_id = request.env['helpdesk.team'].sudo().browse(request.env.ref('helpdesk_morsa.erp_asistense').id)
if team_id:
ticket_dic.update({
'team_id': team_id.id,
'team_head': team_id.team_head.id,
})
if kw.get('portal_erp_type'):
ticket_dic.update({
'erp_type':kw.get('portal_erp_type')
})
if kw.get('portal_erp_type') == 'soporte':
if kw.get('portal_sucursal') and kw.get('portal_sucursal') != 'sucursal':
portal_surcusal_id = request.env['warehouse.helpdesk'].sudo().browse(int(kw.get('portal_sucursal')))
if portal_surcusal_id:
ticket_dic.update({
'warehouse_id':portal_surcusal_id.id
})
if kw.get('portal_module') and kw.get('portal_module') != 'modulo':
portal_module_id = request.env['erp.modules'].sudo().browse(int(kw.get('portal_module')))
if portal_module_id:
ticket_dic.update({
'erp_id':portal_module_id.id
})
else:
self.raise_error("Es necesario el apartado de modulo para crear su ticket")
elif kw.get('portal_erp_type') == 'mejora':
if 'portal_file' not in request.params and 'portal_file_mejora' not in request.params:
return json.dumps({"resp":"Error","message":"Es necesario agregar la archivos"})
else:
return json.dumps({"resp":"Error","message":"El tipo de ticket no se encuentra dentro de los valores"})
else:
return json.dumps({"resp":"Error","message":"No existe tipo de ticket"})
ticket_id = request.env['helpdesk.ticket'].sudo().create(
ticket_dic)
if 'portal_file' in request.params :
attached_files = request.httprequest.files.getlist('portal_file')
attachment_ids = []
for attachment in attached_files:
result = base64.b64encode(attachment.read())
attachment_id = request.env['ir.attachment'].sudo(
).create({
'name': attachment.filename,
'res_model': 'helpdesk.ticket',
'res_id': ticket_id.id,
'display_name': attachment.filename,
'datas': result,
})
attachment_ids.append(attachment_id.id)
ticket_id.attachment_ids = [(6, 0, attachment_ids)]
if 'portal_file_mejora' in request.params :
attached_files = request.httprequest.files.getlist('portal_file_mejora')
attachment_ids = []
for attachment in attached_files:
result = base64.b64encode(attachment.read())
attachment_id = request.env['ir.attachment'].sudo(
).create({
'name': attachment.filename,
'res_model': 'helpdesk.ticket',
'res_id': ticket_id.id,
'display_name': attachment.filename,
'datas': result,
})
attachment_ids.append(attachment_id.id)
ticket_id.attachment_ids = [(6, 0, attachment_ids)]
return request.redirect("/my/erp?ctr=False")
except Exception as e:
_logger.exception('Something went wrong %s',str(e))
@http.route(['/my/erp/<int:ticket_id>'],type='http',auth="public",website=True)
def portal_my_ticket_detail_erp(self,ticket_id,access_token=None,report_type=None,message=False,download=False,**kw):
try:
ticket_sudo = self._document_check_access(
'helpdesk.ticket', ticket_id, access_token=access_token)
except (AccessError, MissingError):
return request.redirect('/my')
if report_type in ('html', 'pdf', 'text'):
return self._show_report(
model=ticket_sudo,
report_type=report_type,
report_ref=
'sh_all_in_one_helpdesk.action_portal_report_helpdesk_ticket',
download=download)
if ticket_sudo:
if request.env.company.sh_receive_email_seeing_ticket:
body = _('Ticket visto por el cliente %s',
ticket_sudo.partner_id.name)
_message_post_helper(
"helpdesk.ticket",
ticket_sudo.id,
body,
token=ticket_sudo.access_token,
message_type="notification",
subtype_xmlid="mail.mt_note",
partner_ids=ticket_sudo.user_id.sudo().partner_id.ids,
)
values = {
'token': access_token,
'asistencia': ticket_sudo,
'message': message,
'bootstrap_formatting': True,
'partner_id': ticket_sudo.partner_id.id,
'report_type': 'html',
}
return request.render("helpdesk_morsa.portal_ticket_page_erp",
values)
from odoo import fields, http, _
from odoo.http import request
from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager
from odoo.tools import date_utils, groupby as groupbyelem
from odoo.osv.expression import AND
from dateutil.relativedelta import relativedelta
from operator import itemgetter
from collections import OrderedDict
from odoo.exceptions import AccessError, MissingError, UserError
from odoo.addons.portal.controllers.mail import _message_post_helper
from datetime import datetime, timedelta
import json
import base64
import werkzeug
import logging
_logger = logging.getLogger(__name__)
from odoo.addons.sh_all_in_one_helpdesk.controllers.portal import PortalHelpdesk
class PortalHelpdeskMorsaSoporte(PortalHelpdesk):
def _prepare_portal_layout_values(self):
values = super(PortalHelpdesk, self)._prepare_portal_layout_values()
stage_close = request.env.ref('sh_all_in_one_helpdesk.close_stage').id
stage_done = request.env.ref('sh_all_in_one_helpdesk.done_stage').id
stage_cancel = request.env.ref('sh_all_in_one_helpdesk.cancel_stage').id
ticket_domain = [('stage_id.id','not in',[stage_close,stage_done,stage_cancel])]
if request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'user':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'leader':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'manager':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('user_id', '=', False))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('sh_user_ids', '=', False))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
ticket_domain.append(('team_head', '=', False))
else:
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('partner_id', '=', request.env.user.partner_id.id))
new_domain_sup = AND([self.prepare_technial_support(), ticket_domain])
support_count = len(request.env['helpdesk.ticket'].sudo().search(new_domain_sup))
tickets = request.env['helpdesk.ticket'].sudo().search(ticket_domain)
values['tickets'] = tickets
values['support_count'] = support_count
return values
def prepare_technial_support(self):
domain = [('team_id.id','=',request.env.ref('helpdesk_morsa.techinnical_support').id)]
return domain
@http.route(['/my/soporte', '/my/soporte/page/<int:page>'],type='http',auth="user",website=True)
def portal_my_soporte(self,ctr='show',page=1,sortby=None,filterby=None,search=None,search_in='all',groupby='create_by',**kw):
values = self._prepare_portal_layout_values()
HelpdeskTicket = request.env['helpdesk.ticket'].sudo()
#domain = self._prepare_technial_support()
searchbar_sortings = {
'create_date': {
'label': _('Newest'),
'order': 'create_date desc'
},
'name': {
'label': _('Name'),
'order': 'name'
},
}
searchbar_inputs = {
'all': {
'input': 'all',
'label': _('Search in All')
},
}
searchbar_groupby = {
'create_by': {
'input': 'create_by',
'label': _('Created By')
},
'ticket_type': {
'input': 'ticket_type',
'label': _('Ticket Type')
},
'status': {
'input': 'status',
'label': _('Status')
},
'customer': {
'input': 'customer',
'label': _('Customer')
},
'category': {
'input': 'category',
'label': _('Category')
},
'subcategory': {
'input': 'subcategory',
'label': _('Sub Category')
},
'subject': {
'input': 'subject',
'label': _('Subject')
},
'priority': {
'input': 'priority',
'label': _('Priority')
},
'state': {
'input': 'state',
'label': _('Reply Status')
},
}
today = fields.Date.today()
quarter_start, quarter_end = date_utils.get_quarter(today)
last_week = today + relativedelta(weeks=-1)
last_month = today + relativedelta(months=-1)
last_year = today + relativedelta(years=-1)
searchbar_filters = {
'all': {
'label': _('All'),
'domain': []
},
'today': {
'label': _('Today'),
'domain': [("create_date", "=", today)]
},
'week': {
'label':
_('This week'),
'domain':
[('create_date', '>=', date_utils.start_of(today, "week")),
('create_date', '<=', date_utils.end_of(today, 'week'))]
},
'month': {
'label':
_('This month'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'month')),
('create_date', '<=', date_utils.end_of(today, 'month'))]
},
'year': {
'label':
_('This year'),
'domain':
[('create_date', '>=', date_utils.start_of(today, 'year')),
('create_date', '<=', date_utils.end_of(today, 'year'))]
},
'quarter': {
'label':
_('This Quarter'),
'domain': [('create_date', '>=', quarter_start),
('create_date', '<=', quarter_end)]
},
'last_week': {
'label':
_('Last week'),
'domain':
[('create_date', '>=', date_utils.start_of(last_week, "week")),
('create_date', '<=', date_utils.end_of(last_week, 'week'))]
},
'last_month': {
'label':
_('Last month'),
'domain':
[('create_date', '>=',
date_utils.start_of(last_month, 'month')),
('create_date', '<=', date_utils.end_of(last_month, 'month'))]
},
'last_year': {
'label':
_('Last year'),
'domain':
[('create_date', '>=', date_utils.start_of(last_year, 'year')),
('create_date', '<=', date_utils.end_of(last_year, 'year'))]
},
}
# default sort by value
if not sortby:
sortby = 'create_date'
order = searchbar_sortings[sortby]['order']
# default filter by value
if not filterby:
filterby = 'all'
domain = AND([searchbar_filters[filterby]['domain']])
if search and search_in:
domain = AND([domain, [('name', 'ilike', search)]])
ticket_domain = self.prepare_technial_support()
if request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'user':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'leader':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
elif request.env.user.sh_portal_user_access and request.env.user.sh_portal_user_access == 'manager':
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(('sh_user_ids', '=', False))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('user_id', '=', False))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
ticket_domain.append(('team_head', '=', request.env.user.id))
ticket_domain.append(('team_head', '=', False))
else:
ticket_domain.append(('|'))
ticket_domain.append(('|'))
ticket_domain.append(('user_id', '=', request.env.user.id))
ticket_domain.append(('sh_user_ids', 'in', [request.env.user.id]))
ticket_domain.append(
('partner_id', '=', request.env.user.partner_id.id))
stage_close = request.env.ref('sh_all_in_one_helpdesk.close_stage').id
stage_done = request.env.ref('sh_all_in_one_helpdesk.done_stage').id
stage_cancel = request.env.ref('sh_all_in_one_helpdesk.cancel_stage').id
ticket_domain.append(('stage_id.id','not in',[stage_close,stage_done,stage_cancel]))
domain = AND([domain, ticket_domain])
support_count = len(HelpdeskTicket.search(domain).filtered(lambda h: h.team_id.id == request.env.ref('helpdesk_morsa.techinnical_support').id))
# pager
pager = portal_pager(url="/my/soporte",url_args={'sortby': sortby,'search_in': search_in,'search': search,'filterby': filterby},total=support_count,page=page,step=self._items_per_page)
if groupby == 'create_by':
order = "create_uid, %s" % order
elif groupby == 'ticket_type':
order = "ticket_type, %s" % order
elif groupby == 'status':
order = "stage_id, %s" % order
elif groupby == 'customer':
order = "partner_id, %s" % order
elif groupby == 'category':
order = "category_id, %s" % order
elif groupby == 'subcategory':
order = "sub_category_id, %s" % order
elif groupby == 'subject':
order = "subject_id, %s" % order
elif groupby == 'priority':
order = "priority, %s" % order
elif groupby == 'state':
order = 'state,%s' % order
tickets = HelpdeskTicket.search(domain,order=order,limit=self._items_per_page,offset=pager['offset'])
request.session['my_tickets_history'] = tickets.ids[:100]
if groupby == 'create_by':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('create_uid'))
]
elif groupby == 'ticket_type':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('ticket_type'))
]
elif groupby == 'status':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('stage_id'))
]
elif groupby == 'customer':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('partner_id'))
]
elif groupby == 'category':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('category_id'))
]
elif groupby == 'subcategory':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('sub_category_id'))
]
elif groupby == 'subject':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('subject_id'))
]
elif groupby == 'priority':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('priority'))
]
elif groupby == 'state':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('state'))
]
# content according to pager and archive selected
values.update({
'created': ctr,
'tickets':tickets,
'grouped_tickets':grouped_tickets,
'page_name':'soporte',
'default_url':'/my/soporte',
'support_count':support_count,
'pager':pager,
'searchbar_sortings':searchbar_sortings,
'search_in':search_in,
'sortby':sortby,
'groupby':groupby,
'searchbar_inputs':searchbar_inputs,
'searchbar_groupby':searchbar_groupby,
'searchbar_filters':OrderedDict(sorted(searchbar_filters.items())),
'filterby':filterby,
'description': "Obtenga ayuda de TI",
})
return request.render("helpdesk_morsa.portal_my_support",values)
@http.route('/portal-create-ticket-soporte', type='http', auth='public',csrf=False)
def portal_create_ticket_support(self, **kw):
try:
_logger.info(kw)
login_user = request.env.user
if login_user and login_user.login != 'public':
partner_id = False
if kw.get('partner_id') and kw.get('partner_id') != '':
partner_id = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1)
else:
partner_id = request.env['res.partner'].sudo().search(
[('email', '=', kw.get('portal_email'))], limit=1)
if not partner_id:
return json.dumps({"resp":"Error","message":"Colaborador no encontrado, favor de verificar que haya agregado uno"})
if partner_id:
unvalued_tickets = len(
request.env['helpdesk.ticket'].sudo().search([
('stage_id','=',request.env.ref('sh_all_in_one_helpdesk.done_stage').id),
('priority_new','=',False)])
)
if unvalued_tickets >= 3:
return json.dumps({"resp":"Error","message":"Tienes demasiados tickets sin evaluar, favor de evaluarlos"})
ticket_dic = {
'partner_id': partner_id.id,
'ticket_from_portal': True
}
if kw.get('portal_phone'):
partner_id.update({'phone': kw.get('portal_phone')})
ticket_dic.update({
'mobile_no':kw.get('portal_phone')
})
if kw.get('portal_contact_name'):
ticket_dic.update({
'person_name':
kw.get('portal_contact_name'),
})
if kw.get('portal_email'):
ticket_dic.update({
'email': kw.get('portal_email'),
})
team_id = request.env['helpdesk.team'].sudo().browse(request.env.ref('helpdesk_morsa.techinnical_support').id)
if team_id:
ticket_dic.update({
'team_id': team_id.id,
'team_head': team_id.team_head.id,
})
ticket_dic.update({'description':False})
ticket_id = request.env['helpdesk.ticket'].sudo().create(
ticket_dic)
if 'portal_file' in request.params:
attached_files = request.httprequest.files.getlist('portal_file')
attachment_ids = []
for attachment in attached_files:
result = base64.b64encode(attachment.read())
attachment_id = request.env['ir.attachment'].sudo(
).create({
'name': attachment.filename,
'res_model': 'helpdesk.ticket',
'res_id': ticket_id.id,
'display_name': attachment.filename,
'datas': result,
})
attachment_ids.append(attachment_id.id)
ticket_id.attachment_ids = [(6, 0, attachment_ids)]
return request.redirect("/my/soporte?ctr=False")
except Exception as e:
_logger.exception('Something went wrong %s',str(e))
@http.route(['/my/soporte/<int:ticket_id>'],type='http',auth="public",website=True)
def portal_my_ticket_detail_soporte(self,ticket_id,access_token=None,report_type=None,message=False,download=False,**kw):
try:
ticket_sudo = self._document_check_access('helpdesk.ticket', ticket_id, access_token=access_token)
except (AccessError, MissingError):
return request.redirect('/my')
if report_type in ('html', 'pdf', 'text'):
return self._show_report(model=ticket_sudo,report_type=report_type,report_ref='sh_all_in_one_helpdesk.action_portal_report_helpdesk_ticket',download=download)
if ticket_sudo:
if request.env.company.sh_receive_email_seeing_ticket:
body = _('Ticket visto por el cliente %s',ticket_sudo.partner_id.name)
_message_post_helper(
"helpdesk.ticket",
ticket_sudo.id,
body,
token=ticket_sudo.access_token,
message_type="notification",
subtype_xmlid="mail.mt_note",
partner_ids=ticket_sudo.user_id.sudo().partner_id.ids,
)
values = {
'token': access_token,
'soporte': ticket_sudo,
'message': message,
'bootstrap_formatting': True,
'partner_id': ticket_sudo.partner_id.id,
'report_type': 'html',
}
return request.render("helpdesk_morsa.portal_ticket_page_support",values)
......@@ -27,7 +27,7 @@ class HelpdeskTicket(models.Model):
('soporte','Soporte'),('mejora','Mejora')
],string="Tipo de asistencia")
ticket_reason = fields.Many2one('ticket.reason','Motivo de Ticket',
default=lambda self: self.env.ref('helpdesk_morsa.reason_anything').id
#default=lambda self: self.env.ref('helpdesk_morsa.reason_anything').id
)
problem_solved_on_time = fields.Boolean('¿Solucionamos complementame tu problema?')
good_service_actitude = fields.Boolean('¿Ha sido buena nuestra actitud de Servicio?')
......
This source diff could not be displayed because it is too large. You can view the blob instead.
.o_background_helpdesk{
background-image: url('/helpdesk_morsa/static/src/img/helpdesk6.svg') !important;
background-repeat: no-repeat;
background-size: cover;
}
.small{
font-size: 12px !important;
font-weight: bold !important;
}
.dropdown-item.active,.dropdown-item.active{
background-color: #386aeb;
}
.bg-light{
box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
}
.navbar-rounded{
border-radius: 30px !important;
background-color: #e4e4e5 !important;
color: #212529;
margin-bottom: 16px;
}
.nav-button{
border-radius: 30px !important;
padding: 0.5rem 1rem;
}
.nav-mr{
margin-right:10px
}
.card-body-custom{
box-shadow: 10px 10px 20px rgba(0,0,0,0.2);
}
.table-responsive{
box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
}
.o_center_object{
display: flex;
align-items: center;
justify-content: center;
}
.o_center_object_right{
display: flex;
align-items: center;
justify-content: flex-end;
}
#portal_answer_question_1,
#portal_answer_question_2,
#portal_answer_question_3{
margin-left:15px;
margin-right:3px;
}
/* Card Styles */
$deeppurple500: #673ab7;
$grey500: #9e9e9e;
.card {
background-color: #ffffff;
text-align: left;
border-radius: 4px;
overflow: hidden;
&__header {
}
&__body {
padding: 16px 0;
}
&__primary-title {
padding: 8px 16px;
h1, h2, h3, h4, h5, h6 { margin: 0; }
}
&__supporting-text {
padding: 8px 16px;
}
&__actions {
padding: 8px;
}
}
/* Material & utility classes */
.bg {
&--deep-purple { color: #ffffff; background-color: $deeppurple500; }
}
.text {
&-normal { font-weight: normal; }
&-bold { font-weight: bold; }
&-secondary { color: $grey500; }
&-small { font-size: 14px; }
&-medium { font-size: 16px; }
&-large { font-size: 24px; }
}
.item {
display: inline-block;
margin-top: 8px;
max-height: 72px;
vertical-align: middle;
&--two-lines {
}
}
.image {
margin: 0;
padding: 0;
overflow: hidden;
&--avatar {
display: inline-block;
margin-right: 16px;
width: 56px;
height: 56px;
border-radius: 50%;
vertical-align: middle;
}
img {
display: inline-block;
width: 100%;
height: auto;
vertical-align: middle;
border: none;
}
}
.btn {
&--icon {
transition: color 0.3s;
&:hover {
color: $grey500;
}
}
}
.depth {
&--two {
box-shadow: 0 3px 12px rgba(0,0,0,0.23), 0 3px 12px rgba(0,0,0,0.16);
}
}
}
\ No newline at end of file
......@@ -32,13 +32,7 @@
<input type="radio" name="smiley" value="4" class="neutral radio_smile" />
<input type="radio" name="smiley" value="3" class="sad radio_smile" />
<input type="radio" name="smiley" value="2" class="very-sad radio_smile" />
<!--<div class="form-group" style="color:white;">
<label for="response">¿Te respondieron antes de los 10 minutos?</label>
<input type="radio" name="attended" id="response" value="Si">Si</input>
<input type="radio" name="attended" id="response" value="No">No</input>
</div>-->
<div class="form-group">
<input type="hidden" name="ticket_id" id="ticket_id" t-att-value="ticket" style="display: none;" />
<label style="color:white;" for="comment">Comentario</label>
......@@ -67,10 +61,6 @@
</xpath>
</template>
<template id="remove_po_db" name="Remove Power and DB manager" inherit_id="vista_backend_theme.code_custom_login">
<xpath expr="//div[@class='text-center small mt-4 pt-3 border-top']" position="replace">
<div></div>
</xpath>
</template>
</odoo>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="portal_edit" name="portal_home_helpdesk" inherit_id="portal.portal_my_home">
<xpath expr="//h3" position="replace">
<h3>Mesa de Ayuda</h3>
</xpath>
<xpath expr="//div[@class='o_portal_docs list-group']" position="attributes">
<attribute name="class">o_portal_docs row</attribute>
</xpath>
</template>
<template id="portal_my_home_ticket" name="Portal My Home : ticket entries" inherit_id="sh_all_in_one_helpdesk.portal_my_home_ticket" priority="30">
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace">
<t t-call="portal.portal_docs_entry">
<t t-set="title">Soporte Técnico</t>
<t t-set="url" t-value="'/my/soporte'" />
<t t-set="count" t-value="support_count" />
<t t-set="desc" t-value="description_support"/>
<t t-set="avatar" t-value="avatar_support"/>
<t t-set="background" t-value="'/helpdesk_morsa/static/src/img/support_back.svg'"/>
</t>
<t t-call="portal.portal_docs_entry">
<t t-set="title">Asistencia ERP / Odoo</t>
<t t-set="url" t-value="'/my/erp'" />
<t t-set="count" t-value="erp_count" />
<t t-set="desc" t-value="description_erp"/>
<t t-set="avatar" t-value="avatar_erp"/>
<t t-set="background" t-value="'/helpdesk_morsa/static/src/img/erp_back.svg'"/>
</t>
<template id="portal_my_home_IT" name="Portal My Home : IT" inherit_id="portal.portal_my_home" priority="100">
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
<t t-call="portal.portal_docs_entry">
<t t-set="title">TI 911</t>
<t t-set="url" t-value="'/my/911'" />
<t t-set="count" t-value="ti_count" />
<t t-set="desc" t-value="description_ti"/>
<t t-set="avatar" t-value="avatar_emergency"/>
<t t-set="background" t-value="'/helpdesk_morsa/static/src/img/emergency_back.svg'"/>
<t t-set="title">Tecnologías de la información</t>
<t t-set="url" t-value="'/my/ti'" />
<t t-set="background" t-value="'/helpdesk_morsa/static/src/img/ti.svg'"/>
</t>
</xpath>
</template>
<template id="remove_invoices" name="remove invoices" inherit_id="account.portal_my_home_invoice">
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace"></xpath>
</template>
<template id="remove_sale_orders" name="remove sale orders" inherit_id="sale.portal_my_home_sale">
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace"></xpath>
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace"></xpath>
</template>
<template id="remove_purchase_orders" name="remove purchase orders" inherit_id="purchase.portal_my_home_purchase">
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace"></xpath>
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace"></xpath>
</template>
<template id="remove_proyects" name="remove proyects" inherit_id="project.portal_my_home">
<xpath expr="//t[@t-call='portal.portal_docs_entry'][4]" position="replace"></xpath>
<xpath expr="//t[@t-call='portal.portal_docs_entry'][4]" position="replace"></xpath>
</template>
<template id="remove_timesheet" name="remove timesheet" inherit_id="hr_timesheet.portal_my_home_timesheet">
<xpath expr="//t[@t-call='portal.portal_docs_entry'][4]" position="replace"></xpath>
</template>
<template id="portal_my_home_menu_ticket" name="Portal layout : ticket menu entries" inherit_id="portal.portal_breadcrumbs" priority="60">
<xpath expr="//ol[hasclass('o_portal_submenu')]" position="inside">
......
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="portal_my_ti" name="Tecnologias de la información">
<t t-call="portal.portal_layout">
<t t-set="my_details" t-value="True"/>
<div class="o_portal_my_home">
<div class="oe_structure" id="oe_structure_portal_my_ti_1"/>
<h3>Mesa de Ayuda</h3>
<div class="o_portal_docs row">
<t t-call="portal.portal_docs_entry">
<t t-set="title">Soporte Técnico</t>
<t t-set="url" t-value="'/my/soporte'" />
<t t-set="count" t-value="support_count" />
<t t-set="desc" t-value="'Obtenga Ayuda de TI'"/>
<t t-set="avatar" t-value="'/helpdesk_morsa/static/src/img/support.svg'"/>
<t t-set="background" t-value="'/helpdesk_morsa/static/src/img/support_back.svg'"/>
</t>
<t t-call="portal.portal_docs_entry">
<t t-set="title">Asistencia ERP / Odoo</t>
<t t-set="url" t-value="'/my/erp'" />
<t t-set="count" t-value="erp_count" />
<t t-set="desc" t-value="'Soporte y Mejoras Odoo'"/>
<t t-set="avatar" t-value="'/helpdesk_morsa/static/src/img/erp.svg'"/>
<t t-set="background" t-value="'/helpdesk_morsa/static/src/img/erp_back.svg'"/>
</t>
<t t-call="portal.portal_docs_entry">
<t t-set="title">TI 911</t>
<t t-set="url" t-value="'/my/911'" />
<t t-set="count" t-value="ti_count" />
<t t-set="desc" t-value="'Emergerncias'"/>
<t t-set="avatar" t-value="'/helpdesk_morsa/static/src/img/emergency.svg'"/>
<t t-set="background" t-value="'/helpdesk_morsa/static/src/img/emergency_back.svg'"/>
</t>
</div>
</div>
<div class="oe_structure" id="oe_structure_portal_my_ti_2"/>
</t>
</template>
</odoo>
\ No newline at end of file
......@@ -15,14 +15,14 @@ _logger = logging.getLogger(__name__)
class HomeInherit(Home):
@http.route('/web/login', type='http', auth="none")
def web_login(self, redirect=None, **kw):
if 'login' in kw and 'password' in kw:
uid = self.auth_user_rpc(kw['login'],kw['password'])
if uid != 0:
return super(HomeInherit, self).web_login(redirect=redirect, **kw)
if 'login' in kw and 'password' in kw:
uid = self.auth_user_rpc(kw['login'],kw['password'])
if uid != 0:
return super(HomeInherit, self).web_login(redirect=redirect, **kw)
else:
return request.redirect('/web/login?error=access')
else:
return request.redirect('/web/login?error=access')
else:
return super(HomeInherit, self).web_login(redirect=redirect, **kw)
return super(HomeInherit, self).web_login(redirect=redirect, **kw)
def auth_user_rpc(self,username,password):
uid = 0
......
# -*- coding: utf-8 -*-
{
"name":"Portal Diseño",
"author":"Arturo Jasso",
"website":"",
"support":"arturo.jasso@morsa.com.mx",
"category":"",
"license":"OPL-1",
"summary":"Actualización de la vista portal, cambio de diseño",
"description":"""Actualización para requerimientos de morsa """,
"version":"15.0.34",
"depends": [
"base",
"portal",
"account",
"sale",
"purchase",
"project",
"vista_backend_theme",
"sh_all_in_one_helpdesk",
"hide_odoo",
],
"data": [
'views/portal_login.xml',
'views/portal_layout.xml',
'views/portal_backend_thanks.xml',
],
'assets': {
'web.assets_frontend': [
'/portal_design_helpdesk/static/src/scss/portal.scss',
],
},
"application":False,
"auto_install":False,
"installable":True,
'images': [],
}
.o_background_helpdesk{
background-image: url('/portal_design_helpdesk/static/src/img/helpdesk6.svg') !important;
background-repeat: no-repeat;
background-size: cover;
}
.small{
font-size: 12px !important;
font-weight: bold !important;
}
.dropdown-item.active,.dropdown-item.active{
background-color: #386aeb;
}
.bg-light{
box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
}
.navbar-rounded{
border-radius: 30px !important;
background-color: #e4e4e5 !important;
color: #212529;
margin-bottom: 16px;
}
.nav-button{
border-radius: 30px !important;
padding: 0.5rem 1rem;
}
.nav-mr{
margin-right:10px
}
.card-body-custom{
box-shadow: 10px 10px 20px rgba(0,0,0,0.2);
}
.table-responsive{
box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
}
.o_center_object{
display: flex;
align-items: center;
justify-content: center;
}
.o_center_object_right{
display: flex;
align-items: center;
justify-content: flex-end;
}
/* Card Styles */
$deeppurple500: #673ab7;
$grey500: #9e9e9e;
.card {
background-color: #ffffff;
text-align: left;
border-radius: 4px;
overflow: hidden;
&__header {
}
&__body {
padding: 16px 0;
}
&__primary-title {
padding: 8px 16px;
h1, h2, h3, h4, h5, h6 { margin: 0; }
}
&__supporting-text {
padding: 8px 16px;
}
&__actions {
padding: 8px;
}
}
/* Material & utility classes */
.bg {
&--deep-purple { color: #ffffff; background-color: $deeppurple500; }
}
.text {
&-normal { font-weight: normal; }
&-bold { font-weight: bold; }
&-secondary { color: $grey500; }
&-small { font-size: 14px; }
&-medium { font-size: 16px; }
&-large { font-size: 24px; }
}
.item {
display: inline-block;
margin-top: 8px;
max-height: 72px;
vertical-align: middle;
&--two-lines {
}
}
.image {
margin: 0;
padding: 0;
overflow: hidden;
&--avatar {
display: inline-block;
margin-right: 16px;
width: 56px;
height: 56px;
border-radius: 50%;
vertical-align: middle;
}
img {
display: inline-block;
width: 100%;
height: auto;
vertical-align: middle;
border: none;
}
}
.btn {
&--icon {
transition: color 0.3s;
&:hover {
color: $grey500;
}
}
}
.depth {
&--two {
box-shadow: 0 3px 12px rgba(0,0,0,0.23), 0 3px 12px rgba(0,0,0,0.16);
}
}
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="remove_po_db" name="Remove Power and DB manager" inherit_id="vista_backend_theme.code_custom_login">
<xpath expr="//div[@class='text-center small mt-4 pt-3 border-top']" position="replace">
<div></div>
</xpath>
</template>
</odoo>
\ No newline at end of file
......@@ -2,12 +2,9 @@
<odoo>
<template id="portal_layout_inherit" name="portal inherit" inherit_id="portal.portal_layout">
<xpath expr="//div[@id='o_my_sidebar']" position="replace">
</xpath>
<xpath expr="//div[@t-attf-class='col-12 col-md col-lg-6']" position="attributes">
<attribute name="t-attf-class">col-12 col-md-12 col-lg-12 col-xl-12 col-sm-12</attribute>-->
<attribute name="t-attf-class">col-12 col-md-12 col-lg-12 col-xl-12 col-sm-12</attribute>
</xpath>
</template>
......@@ -19,33 +16,81 @@
</template>
<template id="portal_edit" name="portal_home_helpdesk" inherit_id="portal.portal_my_home">
<xpath expr="//h3" position="replace">
<h2>BIENVENIDO</h2>
</xpath>
<xpath expr="//div[@class='o_portal_docs list-group']" position="attributes">
<attribute name="class">o_portal_docs row</attribute>
</xpath>
</template>
<template id="remove_invoices" name="remove invoices" inherit_id="account.portal_my_home_invoice">
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace">
<div></div>
</xpath>
</template>
<template id="remove_sale_orders" name="remove sale orders" inherit_id="sale.portal_my_home_sale">
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace">
<div></div>
</xpath>
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace">
<div></div>
</xpath>
</template>
<template id="remove_purchase_orders" name="remove purchase orders" inherit_id="purchase.portal_my_home_purchase">
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace">
<div></div>
</xpath>
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace">
<div></div>
</xpath>
</template>
<template id="remove_proyects" name="remove proyects" inherit_id="project.portal_my_home">
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace"><div></div></xpath>
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace"><div></div></xpath>
</template>
<template id="template_id" name="template_name" inherit_id="sh_all_in_one_helpdesk.portal_my_home_ticket">
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace"><div></div></xpath>
</template>
<template id="remove_timesheet" name="remove timesheet" inherit_id="hr_timesheet.portal_my_home_timesheet">
<xpath expr="//t[@t-call='portal.portal_docs_entry']" position="replace"><div></div></xpath>
</template>
<template id="change_portal_layout" name="portal update docs" inherit_id="portal.portal_docs_entry">
<xpath expr="//a" position="replace">
<div class="col-sm-12 col-md-6 col-lg-4 mb-5">
<div class="card-body card-body-custom" style="background-color:white !important;">
<header class="card__primary-title">
<t t-if="avatar">
<figure class="image image--avatar">
<t t-if="avatar">
<img t-att-src="avatar"/>
</t>
<t t-else="">
<img src="/helpdesk_morsa/static/src/img/13794815201667484387.svg"/>
</t>
<img t-att-src="avatar"/>
</figure>
<div class="item item--two-lines">
<h5 t-att-title="title"><t t-esc="title"/></h5>
</div>
</t>
<div class="item item--two-lines">
<h5 t-att-title="title"><t t-esc="title"/></h5>
</div>
</header>
<figure class="image">
<t t-if="background">
<t t-if="background">
<figure class="image">
<img t-att-src="background"/>
</t>
<t t-else="">
<img src="/helpdesk_morsa/static/src/img/13794815201667484387.svg"/>
</t>
</figure>
<span class="card__supporting-text"><t t-esc="desc"/></span>
</figure>
</t>
<t t-if="desc">
<span class="card__supporting-text"><t t-esc="desc"/></span>
</t>
<footer class="card__actions">
<a class="btn btn-primary" t-att-href="url">Ver mis tickets</a>
</footer>
......@@ -59,8 +104,6 @@
<template id="portal_searchbar_2" name="portal_improvee_searchbar" inherit_id="portal.portal_searchbar">
<xpath expr="//nav" position="replace">
<nav t-attf-class="navbar navbar-rounded border navbar-expand-lg navbar-light {{classes if classes else ''}} {{'mt-3 rounded' if breadcrumbs_searchbar else 'border-top-0' }}">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
......@@ -153,6 +196,5 @@
</nav>
</xpath>
</template>
<!-- -->
</odoo>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment