Commit be9a87e7 by Arturo Jasso Origel

se retiro la restricción de tickets sin valorar, y se agrego la restricción de…

se retiro la restricción de tickets sin valorar, y se agrego la restricción de la creación de adjuntos vacios
parent b6c8bf30
...@@ -349,13 +349,6 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -349,13 +349,6 @@ class PortalCustomerMaintenence(CustomerPortal):
if not partner_id: if not partner_id:
return json.dumps({"resp":"Error","message":"Colaborador no encontrado, favor de verificar que haya agregado uno"}) return json.dumps({"resp":"Error","message":"Colaborador no encontrado, favor de verificar que haya agregado uno"})
if partner_id: 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 = { ticket_dic = {
'partner_id': partner_id.id, 'partner_id': partner_id.id,
'ticket_from_portal': True 'ticket_from_portal': True
...@@ -415,23 +408,22 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -415,23 +408,22 @@ class PortalCustomerMaintenence(CustomerPortal):
ticket_id = request.env['helpdesk.ticket'].sudo().create(ticket_dic) ticket_id = request.env['helpdesk.ticket'].sudo().create(ticket_dic)
if 'portal_file' in request.params: if 'portal_file' in request.params:
attached_files = request.httprequest.files.getlist('portal_file') if kw.get('portal_file'):
attached_files = request.httprequest.files.getlist('portal_file')
attachment_ids = [] attachment_ids = []
for attachment in attached_files: for attachment in attached_files:
result = base64.b64encode(attachment.read()) result = base64.b64encode(attachment.read())
attachment_id = request.env['ir.attachment'].sudo( if result:
).create({ attachment_id = request.env['ir.attachment'].sudo(
'name': attachment.filename, ).create({
'res_model': 'helpdesk.ticket', 'name': attachment.filename,
'res_id': ticket_id.id, 'res_model': 'helpdesk.ticket',
'display_name': attachment.filename, 'res_id': ticket_id.id,
'datas': result, 'display_name': attachment.filename,
}) 'datas': result,
attachment_ids.append(attachment_id.id) })
ticket_id.attachment_ids = [(6, 0, attachment_ids)] attachment_ids.append(attachment_id.id)
ticket_id.attachment_ids = [(6, 0, attachment_ids)]
return request.redirect("/my/mantenimientos?ctr=False") return request.redirect("/my/mantenimientos?ctr=False")
except Exception as e: except Exception as e:
_logger.exception('Something went wrong %s',str(e)) _logger.exception('Something went wrong %s',str(e))
......
$(document).ready(function(e) { $(document).ready(function(e) {
$("#new_request").click(function() { $("#new_request").click(function() {
$("#createticketModalMaintenance").modal("show"); $("#createticketModalMaintenance").modal("show");
}); });
......
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