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
Cool