Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
852 Zobrazení

Hello.


I am trying to assign a client to a helpdesk ticket, I am doing it through the phone number, I search for it in the contacts and the name found should be written in the partner_id field. In certain phone numbers, a modification of the payload message must be made. But in no case does it find the contact even though the phone number registered in Odoo exists.




# Payload data

ticket_contact_phone = payload.get('freshdesk_webhook', {}).get('ticket_contact_phone')


# Delete number '1' in some numbers (MEX ) 

if ticket_contact_phone.startswith('+521'):

    ticket_contact_phone = ticket_contact_phone.replace('+521', '+52', 1)


formatted_phone = ticket_contact_phone

partner_id = False


# Search the contact in Odoo using the full number

partner = env['res.partner'].search([('phone', '=', formatted_phone)], limit=1)


# If the contact is not found, search without the country code

if not partner and len(ticket_contact_phone) > 7:

    formatted_phone_without_country_code = formatted_phone[-7:]

    partner = env['res.partner'].search([('phone', 'ilike', formatted_phone_without_country_code)], limit=1)


if partner:

    partner_id = partner.id


# Create ticket

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

...


    'partner_id': partner_id,


....


})

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
čvc 25
422
1
úno 25
1217
0
zář 23
2160
2
čvn 23
3938
1
srp 22
12712