I created a custom module that overrides the message_new method of the crm.lead model.
But now with the new custom module installed the message_new method isn't being overridden and it's calling the original method from mail.thread.
"/"
from odoo.addons.crm.models.crm_lead import Lead
from odoo import fields, models, api, _
class aLead(models.Model):
_inherit = 'crm.lead'
def message_new(self, msg_dict, custom_values=None):
self = self.with_context(default_user_id=False)
#################
fields=['name','family','mobile','email']
_dict={}
descrip = msg_dict.get('body')
description = descrip.lower()
for line in description.split('\n'):
for field in fields:
if field in line:
split_line=line.split(':')
if len(split_line)>1:
_dict[field]=split_line[1]
################
if custom_values is None:
custom_values = {}
defaults = {
'name': 'v22222222',
'email_from': msg_dict.get('from'),
'email_cc': msg_dict.get('cc'),
'partner_id': msg_dict.get('author_id', False),
'contact_name': _dict.get('name') + '' + _dict.get('family'),
'description': msg_dict.get('body'),
'mobile': _dict.get('mobile'),
'type': 'lead',
}
if msg_dict.get('author_id'):
defaults.update(self._onchange_partner_id_values(msg_dict.get('author_id')))
if msg_dict.get('priority') in dict(crm_stage.AVAILABLE_PRIORITIES):
defaults['priority'] = msg_dict.get('priority')
defaults.update(custom_values)
# assign right company
if 'company_id' not in defaults and 'team_id' in defaults:
defaults['company_id'] = self.env['crm.team'].browse(defaults['team_id']).company_id.id
res = super(Lead, self).message_new(msg_dict, custom_values=defaults)
return res
Lead.message_new = message_new