Ir al contenido
Odoo Menú
  • Inicia sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Inteligencia artificial
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de propiedades
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Comunidad
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    • Referral Program
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

How to add user email as follower when creating Odoo ticket

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
pythontickethelpdeskV16
2 Respuestas
1413 Vistas
Avatar
Hemanth
I have this FastAPI endpoint that creates a ticket in my Odoo helpdesk (V16) application from an external request. How can I obtain the user’s email and add them as a follower to the ticket so they will receive an email whenever we reply?

@helpdesk_api_router.post("/ticket/add")
async def add_ticket(
current_user: Annotated[schemas.User, Depends(user.get_current_active_user)],
request: Request,
request_user_data: schemas.AddTicket,
env=Depends(odoo_env)
):
try:
search_departnment = env["helpdesk.ticket.team"].sudo().search([('id', '=', request_user_data.requestTypeId)])
if not search_departnment:
data = {
"success": "false",
"detail": "Request Type id not found",
}
return JSONResponse(content=data, status_code=404)
# Create ticket
ticket_data = env['helpdesk.ticket'].sudo().create({
'wallet_id': request_user_data.walletId,
'name': search_departnment.name,
'description': request_user_data.description,
'team_id': request_user_data.requestTypeId,
})
data = {
"success": "true",
"ticket_id": ticket_data.id,
"ticket_number": ticket_data.number,
"detail": "Ticket added successfully",
}
return JSONResponse(content=data)
except Exception as e:
# Handle exceptions, log errors, and return an appropriate response
return JSONResponse(content={"detail": "Error processing the ticket"}, status_code=500)


0
Avatar
Descartar
nhavna

Informative, i will copying for future.

Hemanth
Autor

Thanks Pradip, I am referring to the customer who will raise the ticket

Hemanth
Autor

Thank you, Jainesh Shah. If a user replies to the email, I’d like their response to appear in Helpdesk. How can we configure this?

Avatar
Jainesh Shah(Aktiv Software)
Mejor respuesta

Hi Hemanth,


@helpdesk_api_router.post("/ticket/add")

async def add_ticket(

        current_user: Annotated[schemas.User, Depends(user.get_current_active_user)],

        request: Request,

        request_user_data: schemas.AddTicket,

        env=Depends(odoo_env)

):

    try:

        team = env["helpdesk.ticket.team"].sudo().search([

            ('id', '=', request_user_data.requestTypeId)

        ])

        if not team:

            return JSONResponse(

                content={"success": "false", "detail": "Request Type id not found"},

                status_code=404

            )

 

        # -----------------------------------------

        # 1. Create Ticket

        # -----------------------------------------

        ticket = env['helpdesk.ticket'].sudo().create({

            'wallet_id': request_user_data.walletId,

            'name': team.name,

            'description': request_user_data.description,

            'team_id': request_user_data.requestTypeId,

        })

 

        # -----------------------------------------

        #2. CUSTOMER EMAIL from request body

        # NOTE: Adjusting logic according to the email you are getting

        # -----------------------------------------

        customer_email = getattr(request_user_data, "customer_email", None)

 

        if not customer_email:

            print("No customer email found")

        else:

            # -----------------------------------------

            #3. Find or create customer partner

            # -----------------------------------------

            Partner = env['res.partner'].sudo()

            partner = Partner.search([('email', '=', customer_email)], limit=1)

 

            if not partner:

                partner = Partner.create({

                    "name": getattr(request_user_data, "customer_name", customer_email),

                    "email": customer_email,

                })

            else:

                # NEW LINE → Adjust email to match external input

                partner.write({"email": customer_email})

 

            # -----------------------------------------

            #4. Add customer as follower

            # -----------------------------------------

            ticket.message_subscribe(partner_ids=[partner.id])

 

        # -----------------------------------------

        # Response

        # -----------------------------------------

        return JSONResponse(content={

            "success": "true",

            "ticket_id": ticket.id,

            "ticket_number": ticket.number,

            "detail": "Ticket created and customer subscribed",

        })

 

    except Exception as e:

        return JSONResponse(

            content={"detail": "Error processing ticket", "error": str(e)},

            status_code=500

        )


If you have any questions, feel free to reach out.


Hope this helps!


Thanks and Regards,

Email: odoo@aktivsoftware.com

0
Avatar
Descartar
Avatar
Pradip Rangvani
Mejor respuesta
Hi, could you please clarify whether you're referring to an internal user or a customer, and what data you're getting from the request?

If you intend to add an internal user as a follower, you need to assign the user to the user_id field. Alternatively, if you wish to add a customer as a follower, you must assign them to the partner_id field. Based on this, Odoo will automatically add them to the followers list.

0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Handling Media in Odoo Helpdesk via External App Resuelto
ticket helpdesk media V16
Avatar
Avatar
Avatar
2
ene 26
1450
No Notification or Easy Way to Track Email Replies from Customers
ticket email helpdesk V16
Avatar
Avatar
1
mar 26
1832
Reply by email to helpdesk ticket problem Resuelto
ticket helpdesk
Avatar
Avatar
Avatar
3
mar 25
7661
[ODOO 11]: Creating new ticket from automated action not working Resuelto
python ticket automated actions helpdesk
Avatar
1
ene 22
6937
Change sender email address depending on helpdesk
python helpdesk
Avatar
0
ene 22
4351
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now