Help

0

Create ticket from Email

Avatar
Hendra

Hi, I'm using odoo v.10 and using project issue for helpdesk.
I'm able to set email and create project issue from incoming email.

what I want to ask is how to take object from email to helpdesk ticket?
I want to create description from email message value,

currently only ticket title is created from email subject.

Avatar
Discard
2 Answers
0
Avatar
Hendra
Best Answer

Hi, Thank you for the answer, but i'm using project issue module from odoo 10.
so what I do right now is

1. set up incoming mail server

2. set up  "Create a New Record : Project Issue" under " Actions to Perform on Incoming Mails "

This will make every incoming email creating ticket for project issue.
when I send email to create ticket, new ticket created with email subject as the title, but there is no description.
I want to make email content to be ticket description


Avatar
Discard
0
Avatar
Aswanth Babu
Best Answer

HI,

step 1:set incoming email server

step 2: set email alias 

add message_new  function in helpdesk.ticket

use this as example..


@api.model
def message_new(self, msg, custom_values=None):
body = tools.html2plaintext(msg.get('body'))
bre = re.match(r"(.*)^-- *$", body, re.MULTILINE | re.DOTALL | re.UNICODE)
desc = bre.group(1) if bre else None
parent_customer = self.env['res.partner'].browse([msg.get('author_id')]).commercial_partner_id
email_split = tools.email_split(msg.get('email_from'))
values = dict(custom_values or {},
reported_time = msg.get('date'),
reported_by = msg.get('author_id'),
description = desc or body)
create_context = dict(self.env.context or {})
ticket = super(HelpdeskTickets, self.with_context(create_context)).message_new(msg, custom_values=values)
partner_ids = [x for x in ticket._find_partner_from_emails(tools.email_split(msg.get('cc') or '')) if x]
ticket_contacts = [i for i in partner_ids if i in parent_customer.child_ids.ids]
ticket.write({'partner_id': parent_customer.id,
'partner_name':msg.get('email_from').split('<')[0],
'partner_email':email_split[0] if email_split else parent_customer.email,
'contact_ids':[(6,0, ticket_contacts)]})
if partner_ids:
ticket.message_subscribe(partner_ids)
return ticket
Avatar
Discard