在 odoo 中,如何将电子邮件正文的内容与潜在客户中的描述字段相匹配
In odoo how can I match content of the email body to the description field in leads
在通过传入电子邮件自动引导时,我添加了下面显示的代码,说明如何将电子邮件正文添加到描述中,但我得到的是 html 格式
任何人都知道如何将与描述字段相同的电子邮件正文内容添加到描述字段中。
def message_new(self, cr, uid, msg, custom_values=None, context=None):
myString = msg.get('subject', '')
myString.index('Phone:')
mobileNumber = myString[myString.index('Phone:')+6:myString.index('Phone:')+16]
if context is None:
context = {}
data = {}
if isinstance(custom_values, dict):
data = custom_values.copy()
model = context.get('thread_model') or self._name
model_pool = self.pool[model]
fields = model_pool.fields_get(cr, uid, context=context)
if 'name' in fields and not data.get('name'):
data['name'] = msg.get('subject', '')
if 'mobile' in fields and not data.get('mobile'):
data['mobile'] = mobileNumber
if 'description' in fields and not data.get('description'):
data['description'] = msg.get('body', '')
res_id = model_pool.create(cr, uid, data, context=context)
return res_id
试用:
from openerp.tools import html2plaintext
# ...
if 'description' in fields and not data.get('description'):
data['description'] = html2plaintext(msg.get('body')) if msg.get('body') else ''
# ...
在通过传入电子邮件自动引导时,我添加了下面显示的代码,说明如何将电子邮件正文添加到描述中,但我得到的是 html 格式 任何人都知道如何将与描述字段相同的电子邮件正文内容添加到描述字段中。
def message_new(self, cr, uid, msg, custom_values=None, context=None):
myString = msg.get('subject', '')
myString.index('Phone:')
mobileNumber = myString[myString.index('Phone:')+6:myString.index('Phone:')+16]
if context is None:
context = {}
data = {}
if isinstance(custom_values, dict):
data = custom_values.copy()
model = context.get('thread_model') or self._name
model_pool = self.pool[model]
fields = model_pool.fields_get(cr, uid, context=context)
if 'name' in fields and not data.get('name'):
data['name'] = msg.get('subject', '')
if 'mobile' in fields and not data.get('mobile'):
data['mobile'] = mobileNumber
if 'description' in fields and not data.get('description'):
data['description'] = msg.get('body', '')
res_id = model_pool.create(cr, uid, data, context=context)
return res_id
试用:
from openerp.tools import html2plaintext
# ...
if 'description' in fields and not data.get('description'):
data['description'] = html2plaintext(msg.get('body')) if msg.get('body') else ''
# ...