diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-11-30 14:44:49 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-11-30 14:44:49 +0100 |
| commit | 98539336a5d40de748764ff0a3c16d8cda77b02f (patch) | |
| tree | c5b18d5375f4ac458546ff28b29445be9dce0549 /addons/mail | |
| parent | 92f7ecc263ffc252bbec71c9813e12f2933045a2 (diff) | |
| parent | b780e4a0e4389045979fdb82db34e09d4d672cbd (diff) | |
[MERGE] forward port branch saas-14 up to b780e4a0e43
Diffstat (limited to 'addons/mail')
| -rw-r--r-- | addons/mail/models/mail_thread.py | 4 | ||||
| -rw-r--r-- | addons/mail/models/res_users.py | 4 | ||||
| -rw-r--r-- | addons/mail/security/ir.model.access.csv | 2 | ||||
| -rw-r--r-- | addons/mail/tests/test_mail_gateway.py | 17 |
4 files changed, 25 insertions, 2 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index c25c8a36b30..e57f36fae57 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -1366,6 +1366,8 @@ class MailThread(models.AbstractModel): mail module, and should not contain security or generic html cleaning. Indeed those aspects should be covered by the html_sanitize method located in tools. """ + if not body: + return body, attachments root = lxml.html.fromstring(body) postprocessed = False to_remove = [] @@ -1400,7 +1402,7 @@ class MailThread(models.AbstractModel): # Content-Type: multipart/related; # boundary="_004_3f1e4da175f349248b8d43cdeb9866f1AMSPR06MB343eurprd06pro_"; # type="text/html" - if not message.is_multipart() or message.get('content-type', '').startswith("text/"): + if message.get_content_maintype() == 'text': encoding = message.get_content_charset() body = message.get_payload(decode=True) body = tools.ustr(body, encoding, errors='replace') diff --git a/addons/mail/models/res_users.py b/addons/mail/models/res_users.py index a3130c36d44..6dadce7bd9e 100644 --- a/addons/mail/models/res_users.py +++ b/addons/mail/models/res_users.py @@ -2,6 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import _, api, exceptions, fields, models +from odoo.addons.base.res.res_users import is_selection_groups class Users(models.Model): @@ -61,11 +62,14 @@ class Users(models.Model): @api.multi def write(self, vals): write_res = super(Users, self).write(vals) + sel_groups = [vals[k] for k in vals if is_selection_groups(k) and vals[k]] if vals.get('groups_id'): # form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]} user_group_ids = [command[1] for command in vals['groups_id'] if command[0] == 4] user_group_ids += [id for command in vals['groups_id'] if command[0] == 6 for id in command[2]] self.env['mail.channel'].search([('group_ids', 'in', user_group_ids)])._subscribe_users() + elif sel_groups: + self.env['mail.channel'].search([('group_ids', 'in', sel_groups)])._subscribe_users() return write_res def _create_welcome_message(self): diff --git a/addons/mail/security/ir.model.access.csv b/addons/mail/security/ir.model.access.csv index 5040f812d73..1b14cacee0e 100644 --- a/addons/mail/security/ir.model.access.csv +++ b/addons/mail/security/ir.model.access.csv @@ -22,7 +22,7 @@ access_mail_alias_all,mail.alias.all,model_mail_alias,,1,0,0,0 access_mail_alias_user,mail.alias.user,model_mail_alias,base.group_user,1,1,1,1
access_mail_alias_system,mail.alias.system,model_mail_alias,base.group_system,1,1,1,1
access_mail_message_subtype_all,mail.message.subtype.all,model_mail_message_subtype,,1,0,0,0
-access_mail_message_subtype_user,mail.message.subtype.user,model_mail_message_subtype,,1,1,1,1
+access_mail_message_subtype_user,mail.message.subtype.user,model_mail_message_subtype,base.group_user,1,1,1,1
access_mail_tracking_value_all,mail.tracking.value.all,model_mail_tracking_value,,0,0,0,0
access_mail_tracking_value_portal,mail.tracking.value.portal,model_mail_tracking_value,base.group_portal,0,0,0,0
access_mail_tracking_value_user,mail.tracking.value.user,model_mail_tracking_value,base.group_user,0,0,0,0
diff --git a/addons/mail/tests/test_mail_gateway.py b/addons/mail/tests/test_mail_gateway.py index 2a356d9ed13..48f32099592 100644 --- a/addons/mail/tests/test_mail_gateway.py +++ b/addons/mail/tests/test_mail_gateway.py @@ -176,6 +176,19 @@ Content-Type: text/html; --Apple-Mail=_9331E12B-8BD2-4EC7-B53E-01F3FBEC9227-- """ +MAIL_SINGLE_BINARY = """X-Original-To: raoul@grosbedon.fr +Delivered-To: raoul@grosbedon.fr +Received: by mail1.grosbedon.com (Postfix, from userid 10002) + id E8166BFACA; Fri, 23 Aug 2013 13:18:01 +0200 (CEST) +From: "Bruce Wayne" <bruce@wayneenterprises.com> +Content-Type: application/pdf; +Content-Disposition: filename=thetruth.pdf +Content-Transfer-Encoding: base64 +Message-Id: <6BB1FAB2-2104-438E-9447-07AE2C8C4A92@sexample.com> +Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) + +SSBhbSB0aGUgQmF0TWFuCg==""" + MAIL_MULTIPART_IMAGE = """X-Original-To: raoul@example.com Delivered-To: micheline@example.com @@ -349,6 +362,10 @@ class TestMailgateway(TestMail): res.get('body', ''), 'message_parse: second part of the html version should be in body after parsing multipart/mixed') + res = self.env['mail.thread'].message_parse(MAIL_SINGLE_BINARY) + self.assertEqual(res['body'], '') + self.assertEqual(res['attachments'][0][0], 'thetruth.pdf') + @mute_logger('odoo.addons.mail.models.mail_thread') def test_message_process_cid(self): new_groups = self.format_and_process(MAIL_MULTIPART_IMAGE, subject='My Frogs', to='groups@example.com') |
