[FIX] mail.thread subclasses: convert body to plaintext in message_new, as body is now HTML

Also disable the updating of the body when new messages
are received for project.issue records, because this
might discard important information that was manually
entered.

bzr revid: odo@openerp.com-20121009155420-72xvyhhiwd696upv
This commit is contained in:
Olivier Dony 2012-10-09 17:54:20 +02:00
parent 7f516d2835
commit e9d314646d
6 changed files with 22 additions and 9 deletions

View File

@ -26,6 +26,7 @@ from osv import fields, osv
import time
import tools
from tools.translate import _
from tools import html2plaintext
from base.res.res_partner import format_address
@ -812,9 +813,11 @@ class crm_lead(base_stage, format_address, osv.osv):
This override updates the document according to the email.
"""
if custom_values is None: custom_values = {}
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
custom_values.update({
'name': msg.get('subject') or _("No Subject"),
'description': msg.get('body'),
'description': desc,
'email_from': msg.get('from'),
'email_cc': msg.get('cc'),
'user_id': False,

View File

@ -26,6 +26,7 @@ from osv import fields, osv
import time
import tools
from tools.translate import _
from tools import html2plaintext
CRM_CLAIM_PENDING_STATES = (
crm.AVAILABLE_STATES[2][0], # Cancelled
@ -192,9 +193,10 @@ class crm_claim(base_stage, osv.osv):
This override updates the document according to the email.
"""
if custom_values is None: custom_values = {}
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
custom_values.update({
'name': msg.get('subject') or _("No Subject"),
'description': msg.get('body'),
'description': desc,
'email_from': msg.get('from'),
'email_cc': msg.get('cc'),
})

View File

@ -25,6 +25,7 @@ from crm import crm
from osv import fields, osv
import tools
from tools.translate import _
from tools import html2plaintext
CRM_HELPDESK_STATES = (
crm.AVAILABLE_STATES[2][0], # Cancelled
@ -104,9 +105,10 @@ class crm_helpdesk(base_state, base_stage, osv.osv):
This override updates the document according to the email.
"""
if custom_values is None: custom_values = {}
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
custom_values.update({
'name': msg.get('subject') or _("No Subject"),
'description': msg.get('body'),
'description': desc,
'email_from': msg.get('from'),
'email_cc': msg.get('cc'),
'user_id': False,

View File

@ -26,6 +26,7 @@ from base_status.base_stage import base_stage
from datetime import datetime
from osv import fields, osv
from tools.translate import _
from tools import html2plaintext
AVAILABLE_STATES = [
('draft', 'New'),
@ -327,9 +328,10 @@ class hr_applicant(base_stage, osv.Model):
This override updates the document according to the email.
"""
if custom_values is None: custom_values = {}
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
custom_values.update({
'name': msg.get('subject') or _("No Subject"),
'description': msg.get('body'),
'description': desc,
'email_from': msg.get('from'),
'email_cc': msg.get('cc'),
'user_id': False,

View File

@ -19,12 +19,14 @@
#
##############################################################################
from base_status.base_stage import base_stage
from datetime import datetime, date
import time
from lxml import etree
from datetime import datetime, date
import tools
from base_status.base_stage import base_stage
from osv import fields, osv
from openerp.addons.resource.faces import task as Task
import time
from tools.translate import _
from openerp import SUPERUSER_ID

View File

@ -27,6 +27,7 @@ from tools.translate import _
import binascii
import time
import tools
from tools import html2plaintext
class project_issue_version(osv.osv):
_name = "project.issue.version"
@ -462,9 +463,11 @@ class project_issue(base_stage, osv.osv):
if context is None: context = {}
context['state_to'] = 'draft'
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
custom_values.update({
'name': msg.get('subject') or _("No Subject"),
'description': msg.get('body'),
'description': desc,
'email_from': msg.get('from'),
'email_cc': msg.get('cc'),
'user_id': False,
@ -486,7 +489,6 @@ class project_issue(base_stage, osv.osv):
if update_vals is None: update_vals = {}
# Update doc values according to the message
update_vals['description'] = msg.get('body', '')
if msg.get('priority'):
update_vals['priority'] = msg.get('priority')
# Parse 'body' to find values to update