跳至內容
選單
此問題已被標幟
881 瀏覽次數

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,


....


})

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
7月 25
481
1
2月 25
1242
0
9月 23
2185
2
6月 23
3998
1
8月 22
12748