Commit 0fee9a34 by Arturo Jasso Origel

se agregó a la creación de usuarios la verificación del contacto, para evitar…

se agregó a la creación de usuarios la verificación del contacto, para evitar que salgan contactos repetidos y sin usuario
parent 9dc71f19
...@@ -38,9 +38,10 @@ class PortalHelpdeskMorsa(PortalHelpdesk): ...@@ -38,9 +38,10 @@ class PortalHelpdeskMorsa(PortalHelpdesk):
partner = request.env['res.partner'].sudo().search( partner = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1) [('id', '=', int(kw.get('partner_id')))], limit=1)
if partner: if partner:
email = partner.email if partner.email else partner.user_ids[0].login
dic.update({ dic.update({
'name': partner.name, 'name': partner.name,
'email': partner.email, 'email': email,
'phone': partner.phone, 'phone': partner.phone,
}) })
......
...@@ -348,12 +348,15 @@ class PortalHelpdeskMorsaEmergency(PortalHelpdesk): ...@@ -348,12 +348,15 @@ class PortalHelpdeskMorsaEmergency(PortalHelpdesk):
partner_id = False partner_id = False
if kw.get('partner_id') and kw.get('partner_id') != '': if kw.get('partner_id') and kw.get('partner_id') != '':
partner_id = request.env['res.partner'].sudo().search( partner_id = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1) [('id', '=', int(kw.get('partner_id')))]).filtered(lambda user: len(user.user_ids) > 0 )
else: else:
partner_id = request.env['res.partner'].sudo().search( partner_id = request.env['res.partner'].sudo().search(
[('email', '=', kw.get('portal_email'))], limit=1) [('email', '=', kw.get('portal_email'))]).filtered(lambda user: len(user.user_ids) > 0 )
if partner_id and len(partner_id) > 1:
partner_id = request.env.user.partner_id
if not partner_id: if not partner_id:
return json.dumps({"resp":"Error","message":"No hay contacto"}) 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( unvalued_tickets = len(
request.env['helpdesk.ticket'].sudo().search([ request.env['helpdesk.ticket'].sudo().search([
......
...@@ -367,12 +367,15 @@ class PortalHelpdeskMorsaErp(PortalHelpdesk): ...@@ -367,12 +367,15 @@ class PortalHelpdeskMorsaErp(PortalHelpdesk):
partner_id = False partner_id = False
if kw.get('partner_id') and kw.get('partner_id') != '': if kw.get('partner_id') and kw.get('partner_id') != '':
partner_id = request.env['res.partner'].sudo().search( partner_id = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1) [('id', '=', int(kw.get('partner_id')))]).filtered(lambda user: len(user.user_ids) > 0 )
else: else:
partner_id = request.env['res.partner'].sudo().search( partner_id = request.env['res.partner'].sudo().search(
[('email', '=', kw.get('portal_email'))], limit=1) [('email', '=', kw.get('portal_email'))]).filtered(lambda user: len(user.user_ids) > 0 )
if partner_id and len(partner_id) > 1:
partner_id = request.env.user.partner_id
if not partner_id: if not partner_id:
return json.dumps({"resp":"Error","message":"Colaborador no encontrado, favor de verificar que haya agregado uno existente"}) 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( unvalued_tickets = len(
request.env['helpdesk.ticket'].sudo().search([ request.env['helpdesk.ticket'].sudo().search([
......
...@@ -350,10 +350,12 @@ class PortalHelpdeskMorsaSoporte(PortalHelpdesk): ...@@ -350,10 +350,12 @@ class PortalHelpdeskMorsaSoporte(PortalHelpdesk):
partner_id = False partner_id = False
if kw.get('partner_id') and kw.get('partner_id') != '': if kw.get('partner_id') and kw.get('partner_id') != '':
partner_id = request.env['res.partner'].sudo().search( partner_id = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1) [('id', '=', int(kw.get('partner_id')))]).filtered(lambda user: len(user.user_ids) > 0 )
else: else:
partner_id = request.env['res.partner'].sudo().search( partner_id = request.env['res.partner'].sudo().search(
[('email', '=', kw.get('portal_email'))], limit=1) [('email', '=', kw.get('portal_email'))]).filtered(lambda user: len(user.user_ids) > 0 )
if partner_id and len(partner_id) > 1:
partner_id = request.env.user.partner_id
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"})
......
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