summaryrefslogtreecommitdiff
path: root/addons/mail
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2015-01-19 17:15:56 +0100
committerChristophe Simonis <chs@odoo.com>2015-01-19 17:15:56 +0100
commit18e22be138f4d273ce8f63c0ff2c8a437cf6ce5d (patch)
tree63bd658de7b6fa0e91d521ca19322dd68bdc1492 /addons/mail
parentf6e5bf847b1a7107c09b009a757823b0f9514fa4 (diff)
parent0aab81cd3ac6881b2b64ccedb901b55badd421d4 (diff)
[MERGE] forward port of branch 8.0 up to 0aab81c
Diffstat (limited to 'addons/mail')
-rw-r--r--addons/mail/__openerp__.py8
-rw-r--r--addons/mail/mail_thread.py38
-rw-r--r--addons/mail/static/src/js/mail.js10
-rw-r--r--addons/mail/tests/__init__.py11
-rw-r--r--addons/mail/tests/test_mail_gateway.py12
-rw-r--r--addons/mail/wizard/mail_compose_message.py2
6 files changed, 50 insertions, 31 deletions
diff --git a/addons/mail/__openerp__.py b/addons/mail/__openerp__.py
index 642aeb1bca8..a7a96617119 100644
--- a/addons/mail/__openerp__.py
+++ b/addons/mail/__openerp__.py
@@ -75,14 +75,6 @@ Main Features
],
'installable': True,
'application': True,
- 'images': [
- 'images/inbox.jpeg',
- 'images/messages_form.jpeg',
- 'images/messages_list.jpeg',
- 'images/email.jpeg',
- 'images/join_a_group.jpeg',
- 'images/share_a_message.jpeg',
- ],
'qweb': [
'static/src/xml/mail.xml',
'static/src/xml/mail_followers.xml',
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 254cd193285..4e3e77f1dd8 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -1443,18 +1443,34 @@ class mail_thread(osv.AbstractModel):
if follower.email == email_address:
partner_id = follower.id
# second try: check in partners that are also users
+ # Escape special SQL characters in email_address to avoid invalid matches
+ email_address = (email_address.replace('\\', '\\\\').replace('%', '\\%').replace('_', '\\_'))
+ email_brackets = "<%s>" % email_address
if not partner_id:
- ids = partner_obj.search(cr, SUPERUSER_ID, [
- ('email', 'ilike', email_address),
- ('user_ids', '!=', False)
- ], limit=1, context=context)
+ # exact, case-insensitive match
+ ids = partner_obj.search(cr, SUPERUSER_ID,
+ [('email', '=ilike', email_address),
+ ('user_ids', '!=', False)],
+ limit=1, context=context)
+ if not ids:
+ # if no match with addr-spec, attempt substring match within name-addr pair
+ ids = partner_obj.search(cr, SUPERUSER_ID,
+ [('email', 'ilike', email_brackets),
+ ('user_ids', '!=', False)],
+ limit=1, context=context)
if ids:
partner_id = ids[0]
# third try: check in partners
if not partner_id:
- ids = partner_obj.search(cr, SUPERUSER_ID, [
- ('email', 'ilike', email_address)
- ], limit=1, context=context)
+ # exact, case-insensitive match
+ ids = partner_obj.search(cr, SUPERUSER_ID,
+ [('email', '=ilike', email_address)],
+ limit=1, context=context)
+ if not ids:
+ # if no match with addr-spec, attempt substring match within name-addr pair
+ ids = partner_obj.search(cr, SUPERUSER_ID,
+ [('email', 'ilike', email_brackets)],
+ limit=1, context=context)
if ids:
partner_id = ids[0]
partner_ids.append(partner_id)
@@ -1474,13 +1490,15 @@ class mail_thread(osv.AbstractModel):
partner_id = partner_ids[idx]
partner_info = {'full_name': email_address, 'partner_id': partner_id}
result.append(partner_info)
-
# link mail with this from mail to the new partner id
if link_mail and partner_info['partner_id']:
+ # Escape special SQL characters in email_address to avoid invalid matches
+ email_address = (email_address.replace('\\', '\\\\').replace('%', '\\%').replace('_', '\\_'))
+ email_brackets = "<%s>" % email_address
message_ids = mail_message_obj.search(cr, SUPERUSER_ID, [
'|',
- ('email_from', '=', email_address),
- ('email_from', 'ilike', '<%s>' % email_address),
+ ('email_from', '=ilike', email_address),
+ ('email_from', 'ilike', email_brackets),
('author_id', '=', False)
], context=context)
if message_ids:
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index 59c1eaecd89..d54ad6176b1 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -369,6 +369,16 @@ openerp.mail = function (session) {
this.is_log = false;
this.recipients = [];
this.recipient_ids = [];
+ session.web.bus.on('clear_uncommitted_changes', this, function(e) {
+ if (this.show_composer && !e.isDefaultPrevented()){
+ if (!confirm(_t("You are currently composing a message, your message will be discarded.\n\nAre you sure you want to leave this page ?"))) {
+ e.preventDefault();
+ }
+ else{
+ this.on_cancel();
+ }
+ }
+ });
},
start: function () {
diff --git a/addons/mail/tests/__init__.py b/addons/mail/tests/__init__.py
index e5592468cb4..23162ee1c2f 100644
--- a/addons/mail/tests/__init__.py
+++ b/addons/mail/tests/__init__.py
@@ -20,14 +20,3 @@
##############################################################################
from . import test_mail_group, test_mail_message, test_mail_features, test_mail_gateway, test_message_read, test_invite, test_mail, test_ir_actions
-
-checks = [
- test_mail_group,
- test_mail_message,
- test_mail_features,
- test_mail_gateway,
- test_message_read,
- test_invite,
- test_mail,
- test_ir_actions,
-]
diff --git a/addons/mail/tests/test_mail_gateway.py b/addons/mail/tests/test_mail_gateway.py
index 5de41cc5d7a..cc732b007a2 100644
--- a/addons/mail/tests/test_mail_gateway.py
+++ b/addons/mail/tests/test_mail_gateway.py
@@ -68,7 +68,7 @@ MAIL_TEMPLATE_PLAINTEXT = """Return-Path: <whatever-2a840@postmaster.twitter.com
To: {to}
Received: by mail1.openerp.com (Postfix, from userid 10002)
id 5DF9ABFB2A; Fri, 10 Aug 2012 16:16:39 +0200 (CEST)
-From: Sylvie Lelitre <sylvie.lelitre@agrolait.com>
+From: Sylvie Lelitre <test.sylvie.lelitre@agrolait.com>
Subject: {subject}
MIME-Version: 1.0
Content-Type: text/plain
@@ -525,6 +525,16 @@ class TestMailgateway(TestMail):
self.assertEqual(frog_group.message_ids[0].author_id.id, extra_partner_id,
'message_process: email_from -> author_id wrong')
+ # Do: post a new message with a non-existant email that is a substring of a partner email
+ format_and_process(MAIL_TEMPLATE, email_from='Not really Lombrik Lubrik <oul@email.com>',
+ subject='Re: news (2)',
+ msg_id='<zzzbbbaaaa@agrolait.com>',
+ extra='In-Reply-To: <1198923581.41972151344608186760.JavaMail@agrolait.com>\n')
+ frog_groups = self.mail_group.search(cr, uid, [('name', '=', 'Frogs')])
+ frog_group = self.mail_group.browse(cr, uid, frog_groups[0])
+ # Test: author must not be set, otherwise the system is confusing different users
+ self.assertFalse(frog_group.message_ids[0].author_id, 'message_process: email_from -> mismatching author_id')
+
# Do: post a new message, with a known partner -> duplicate emails -> user
frog_group.message_unsubscribe([extra_partner_id])
self.res_users.write(cr, uid, self.user_raoul_id, {'email': 'test_raoul@email.com'})
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index 49eaa599888..485869dd6fe 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -286,7 +286,7 @@ class mail_compose_message(osv.TransientModel):
batch_mail_mail_ids.append(mail_mail_id)
else:
subtype = 'mail.mt_comment'
- if context.get('mail_compose_log') or (wizard.composition_mode == 'mass_post' and not wizard.notify): # log a note: subtype is False
+ if wizard.is_log or (wizard.composition_mode == 'mass_post' and not wizard.notify): # log a note: subtype is False
subtype = False
if wizard.composition_mode == 'mass_post':
context = dict(context,