Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Artificial Intelligence
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Property Management
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

How to add user email as follower when creating Odoo ticket

Subscriure's

Get notified when there's activity on this post

This question has been flagged
pythontickethelpdeskV16
2 Respostes
1397 Vistes
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)
Best Answer

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
Best Answer
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
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
Handling Media in Odoo Helpdesk via External App Solved
ticket helpdesk media V16
Avatar
Avatar
Avatar
2
de gen. 26
1419
No Notification or Easy Way to Track Email Replies from Customers
ticket email helpdesk V16
Avatar
Avatar
1
de març 26
1799
Reply by email to helpdesk ticket problem Solved
ticket helpdesk
Avatar
Avatar
Avatar
3
de març 25
7596
[ODOO 11]: Creating new ticket from automated action not working Solved
python ticket automated actions helpdesk
Avatar
1
de gen. 22
6917
Change sender email address depending on helpdesk
python helpdesk
Avatar
0
de gen. 22
4321
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

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