Merge pull request #724 from odoo-dev/7.0-mail_issues-fix-adh

[FIX] mail: misc bug fixing
- avoid deleting the Whole Company mail group if still present, because it is required for some module installation. In 7.0 installing some modules may crash if this group is not present.
- fixed an issue when computing possible recipients in the Chatter
- small fix in html2plaintext about blank lines
This commit is contained in:
Thibault Delavallée 2014-07-10 22:50:53 +02:00
commit 67f1fd8a53
3 changed files with 11 additions and 4 deletions

View File

@ -24,7 +24,7 @@ import openerp.tools as tools
from openerp.osv import osv
from openerp.osv import fields
from openerp import SUPERUSER_ID
from openerp.tools.translate import _
class mail_group(osv.Model):
""" A mail_group is a collection of users sharing messages in a discussion
@ -172,6 +172,12 @@ class mail_group(osv.Model):
mail_alias = self.pool.get('mail.alias')
alias_ids = [group.alias_id.id for group in groups if group.alias_id]
# Delete mail_group
try:
all_emp_group = self.pool['ir.model.data'].get_object_reference(cr, uid, 'mail', 'group_all_employees')[1]
except ValueError:
all_emp_group = None
if all_emp_group and all_emp_group in ids:
raise osv.except_osv(_('Warning!'), _('You cannot delete those groups, as the Whole Company group is required by other modules.'))
res = super(mail_group, self).unlink(cr, uid, ids, context=context)
# Delete alias
mail_alias.unlink(cr, SUPERUSER_ID, alias_ids, context=context)

View File

@ -951,7 +951,7 @@ class mail_thread(osv.AbstractModel):
return result
if partner and partner in obj.message_follower_ids: # recipient already in the followers -> skip
return result
if partner and partner in [val[0] for val in result[obj.id]]: # already existing partner ID -> skip
if partner and partner.id in [val[0] for val in result[obj.id]]: # already existing partner ID -> skip
return result
if partner and partner.email: # complete profile: id, name <email>
result[obj.id].append((partner.id, '%s<%s>' % (partner.name, partner.email), reason))

View File

@ -211,10 +211,11 @@ def html2plaintext(html, body_id=None, encoding='utf-8'):
html = re.sub('<br\s*/?>', '\n', html)
html = re.sub('<.*?>', ' ', html)
html = html.replace(' ' * 2, ' ')
html = html.replace('&gt;', '>')
html = html.replace('&lt;', '<')
# strip all lines
html = '\n'.join([x.strip() for x in html.splitlines()])
html = html.replace('\n' * 2, '\n')
html = ''.join([x.strip() for x in html.splitlines(True)])
for i, url in enumerate(url_index):
if i == 0: