diff --git a/addons/base_import/static/src/css/import.css b/addons/base_import/static/src/css/import.css index 21e598ff707..07b193c3dc4 100644 --- a/addons/base_import/static/src/css/import.css +++ b/addons/base_import/static/src/css/import.css @@ -1,3 +1,54 @@ +.oe_import{ + display: inline-block; + width: 600px; + padding: 16px; +} +.oe_import > p { + margin-left: 8px; + margin-right: 8px; + text-align: justify +} + +/* ----------- IMPORT BOX ----------- */ + +.oe_import .oe_import_box{ + margin: 16px; + padding: 16px; + background: #F0EEEE; + border-radius: 3px; + border: solid 1px #dddddd; +} +.oe_import .oe_import_toggle{ + margin-top: 8px; +} +.oe_import .oe_import_options{ + margin-top: 8px; +} +.oe_import .oe_import_options input{ + width: 150px; +} + +.oe_import a.oe_import_toggle { + display: block; +} +.oe_import a.oe_import_toggle:before { + content: '+' +} + +.oe_import .oe_import_options p { + margin: 0; + padding: 0; +} +.oe_import .oe_import_options label { + display: inline-block; + width: 100px; + height:32px; + line-height:32px; + text-align: right; +} + +/* ----------- INITIAL SETUP ------------ */ + .openerp .oe_list_buttons .oe_alternative { visibility: visible; } @@ -25,38 +76,85 @@ display: block; } -.oe_import .oe_import_error_report ul .oe_import_report_error { - background-color: #FFD9DB; -} -.oe_import .oe_import_error_report ul .oe_import_report_warning { - background-color: #FEFFD9; -} -.oe_import .oe_import_error_report ul .oe_import_report_info { - background-color: #d3ffd3; -} - .oe_import .oe_import_noheaders { color: #888; } -.oe_import a.oe_import_toggle { - display: block; -} -.oe_import a.oe_import_toggle:before { - content: '> ' -} - -.oe_import .oe_import_options p { - margin: 0; - padding: 0; -} -.oe_import .oe_import_options label { - display: inline-block; - width: 8em; - text-align: right; -} .oe_import_selector ul, .oe_import_selector li { margin: 0; padding: 0; } + +/* ------------- ERRORS AND WARNINGS REPORT ------------ */ + +.oe_import .oe_import_error_report ul{ + padding-left: 16px; +} +.oe_import .oe_import_report { + margin-right: 16px; + padding: 4px; + list-style: none; + border-bottom: solid 1px rgba(0,0,0,0.05); +} +.oe_import .oe_import_report:first-child{ + border-top-left-radius: 3px; + border-top-right-radius: 3px; +} +.oe_import .oe_import_report:last-child{ + border-bottom-left-radius:3px; + border-bottom-right-radius:3px; + border-bottom: none; +} +.oe_import .oe_import_report_error { + background-color: #FFD9DB; + color: #AF5F5E; +} +.oe_import .oe_import_report_error:last-of-type{ + border-bottom:none; +} +.oe_import .oe_import_report_warning { + background-color: #FEFFD9; + color: #918743; +} +.oe_import .oe_import_report_warning:last-of-type{ + border-bottom:none; +} +.oe_import .oe_import_report_info { + background-color: #d3ffd3; +} +.oe_import .oe_import_report_info:last-of-type{ + border-bottom:none; +} + +/* ------------- THE CSV TABLE ------------ */ + +.oe_import .oe_import_grid{ + margin: 16px; + border-radius:3px; + border: solid 1px #909090; +} +.oe_import .oe_import_grid tr{ + height:16px; +} +.oe_import .oe_import_grid tr.oe_import_grid-header:first-child{ + height: 24px; + background: #909090; + color: white; +} +.oe_import .oe_import_grid tr:nth-child(odd){ + background: rgba(0,0,0,0.05); +} +.oe_import .oe_import_grid td{ + padding: 2px; + padding-left: 4px; +} +.oe_import .oe_import_grid tr.oe_import_grid-header td:not(:last-child){ + border-right: 1px solid #707070; +} +.oe_import .oe_import_grid td:not(:last-child){ + border-right: 1px solid #D0D0D0; +} + + + diff --git a/addons/base_import/static/src/xml/import.xml b/addons/base_import/static/src/xml/import.xml index 1c57c40c9db..4f721032d1d 100644 --- a/addons/base_import/static/src/xml/import.xml +++ b/addons/base_import/static/src/xml/import.xml @@ -21,24 +21,26 @@ class="oe_import_csv" target="_blank">.CSV file to import. If you need a sample importable file, you can use the export tool to generate one.
- - - -- - - -
++ + + +
+\nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n\n', 'plaintext mail incorrectly parsed') - def test_10_many2many_reference_field(self): + def test_10_followers_function_field(self): """ Tests designed for the many2many function field 'follower_ids'. We will test to perform writes using the many2many commands 0, 3, 4, 5 and 6. """ - cr, uid = self.cr, self.uid - user_admin = self.res_users.browse(cr, uid, uid) - group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) + cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs - # Create partner Bert Poilu + # Data: create partner Bert Poilu partner_bert_id = self.res_partner.create(cr, uid, {'name': 'Bert Poilu'}) - - # Create 'disturbing' values in mail.followers: same res_id, other res_model; same res_model, other res_id + # Data: create 'disturbing' values in mail.followers: same res_id, other res_model; same res_model, other res_id group_dummy_id = self.mail_group.create(cr, uid, {'name': 'Dummy group'}) self.mail_followers.create(cr, uid, @@ -257,9 +258,7 @@ class test_mail(TestMailMockups): def test_11_message_followers_and_subtypes(self): """ Tests designed for the subscriber API as well as message subtypes """ - cr, uid = self.cr, self.uid - user_admin = self.res_users.browse(cr, uid, uid) - group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) + cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs # Data: user Raoul user_raoul_id = self.res_users.create(cr, uid, {'name': 'Raoul Grosbedon', 'login': 'raoul'}) user_raoul = self.res_users.browse(cr, uid, user_raoul_id) @@ -281,7 +280,6 @@ class test_mail(TestMailMockups): group_pigs.refresh() # Test: 2 followers (Admin and Raoul) follower_ids = [follower.id for follower in group_pigs.message_follower_ids] - self.assertEqual(len(follower_ids), 2, 'There should be 2 Pigs fans') self.assertEqual(set(follower_ids), set([user_raoul.partner_id.id, user_admin.partner_id.id]), 'Admin and Raoul should be the only 2 Pigs fans') # Test: Raoul follows default subtypes fol_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id), ('partner_id', '=', user_raoul.partner_id.id)]) @@ -307,19 +305,16 @@ class test_mail(TestMailMockups): # CASE2: test mail_thread fields # ---------------------------------------- - group_pigs.refresh() - self.assertEqual(set(group_pigs.message_subtype_data.keys()), set(['comment', 'mt_mg_def', 'mt_all_def', 'mt_mg_nodef', 'mt_all_nodef']), 'mail.group available subtypes incorrect') - self.assertFalse(group_pigs.message_subtype_data['comment']['followed'], 'Admin should not follow comments in pigs') - self.assertTrue(group_pigs.message_subtype_data['mt_mg_nodef']['followed'], 'Admin should follow mt_mg_nodef in pigs') - self.assertTrue(group_pigs.message_subtype_data['mt_all_nodef']['followed'], 'Admin should follow mt_all_nodef in pigs') + subtype_data = group_pigs._get_subscription_data(None, None)[group_pigs.id]['message_subtype_data'] + self.assertEqual(set(subtype_data.keys()), set(['comment', 'mt_mg_def', 'mt_all_def', 'mt_mg_nodef', 'mt_all_nodef']), 'mail.group available subtypes incorrect') + self.assertFalse(subtype_data['comment']['followed'], 'Admin should not follow comments in pigs') + self.assertTrue(subtype_data['mt_mg_nodef']['followed'], 'Admin should follow mt_mg_nodef in pigs') + self.assertTrue(subtype_data['mt_all_nodef']['followed'], 'Admin should follow mt_all_nodef in pigs') def test_20_message_post(self): """ Tests designed for message_post. """ - cr, uid = self.cr, self.uid + cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs self.res_users.write(cr, uid, [uid], {'signature': 'Admin', 'email': 'a@a'}) - user_admin = self.res_users.browse(cr, uid, uid) - group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) - # 1 - Bert Tartopoils, with email, should receive emails for comments and emails p_b_id = self.res_partner.create(cr, uid, {'name': 'Bert Tartopoils', 'email': 'b@b'}) # 2 - Carine Poilvache, with email, should never receive emails @@ -345,11 +340,12 @@ class test_mail(TestMailMockups): # CASE1: post comment, body and subject specified # ---------------------------------------- + # 1. Post a new comment on Pigs self._init_mock_build_email() msg_id = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body1, subject=_subject, type='comment', subtype='mt_comment') message = self.mail_message.browse(cr, uid, msg_id) sent_emails = self._build_email_kwargs_list - # Test: notifications have been deleted + # Test: mail.mail notifications have been deleted self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg_id)]), 'mail.mail notifications should have been auto-deleted!') # Test: mail_message: subject is _subject, body is _body1 (no formatting done) self.assertEqual(message.subject, _subject, 'mail.message subject incorrect') @@ -377,19 +373,18 @@ class test_mail(TestMailMockups): # CASE2: post an email with attachments, parent_id, partner_ids # ---------------------------------------- - # TESTS: automatic subject, signature in body_html, attachments propagation + # 1. Post a new email comment on Pigs self._init_mock_build_email() msg_id2 = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body2, type='email', subtype='mt_comment', partner_ids=[(6, 0, [p_d_id])], parent_id=msg_id, attachments=_attachments) message = self.mail_message.browse(cr, uid, msg_id2) sent_emails = self._build_email_kwargs_list self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg_id2)]), 'mail.mail notifications should have been auto-deleted!') - # Test: mail_message: subject is False, body is _body2 (no formatting done), parent_id is msg_id self.assertEqual(message.subject, False, 'mail.message subject incorrect') self.assertEqual(message.body, html_sanitize(_body2), 'mail.message body incorrect') self.assertEqual(message.parent_id.id, msg_id, 'mail.message parent_id incorrect') - # Test: sent_email: email send by server: correct subject, body, body_alternative + # Test: sent_email: email send by server: correct automatic subject, body, body_alternative self.assertEqual(len(sent_emails), 2, 'sent_email number of sent emails incorrect') for sent_email in sent_emails: self.assertEqual(sent_email['subject'], _mail_subject, 'sent_email subject incorrect') @@ -413,13 +408,11 @@ class test_mail(TestMailMockups): self.assertIn((attach.name, attach.datas.decode('base64')), _attachments, 'mail.message attachment name / data incorrect') - def test_21_message_compose_wizard(self): + def test_25_message_compose_wizard(self): """ Tests designed for the mail.compose.message wizard. """ - cr, uid = self.cr, self.uid + cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs mail_compose = self.registry('mail.compose.message') self.res_users.write(cr, uid, [uid], {'signature': 'Admin', 'email': 'a@a'}) - user_admin = self.res_users.browse(cr, uid, uid) - group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) group_bird_id = self.mail_group.create(cr, uid, {'name': 'Bird', 'description': 'Bird resistance'}) group_bird = self.mail_group.browse(cr, uid, group_bird_id) @@ -434,7 +427,6 @@ class test_mail(TestMailMockups): ] _attachments_test = [('first.txt', 'My first attachment'), ('second.txt', 'My second attachment')] - # Create partners # 1 - Bert Tartopoils, with email, should receive emails for comments and emails p_b_id = self.res_partner.create(cr, uid, {'name': 'Bert Tartopoils', 'email': 'b@b'}) # 2 - Carine Poilvache, with email, should never receive emails @@ -470,7 +462,6 @@ class test_mail(TestMailMockups): msg_pids = [partner.id for partner in message.partner_ids] test_pids = [p_b_id, p_c_id, p_d_id] notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', message.id)]) - self.assertEqual(len(notif_ids), 3, 'mail.message: too much notifications created') self.assertEqual(set(msg_pids), set(test_pids), 'mail.message partner_ids incorrect') @@ -505,7 +496,7 @@ class test_mail(TestMailMockups): # 1. mass_mail on pigs and bird compose_id = mail_compose.create(cr, uid, - {'subject': _subject, 'body': '${object.description}', 'content_type': 'html'}, + {'subject': _subject, 'body': '${object.description}', 'content_subtype': 'html'}, {'default_composition_mode': 'mass_mail', 'default_model': 'mail.group', 'default_res_id': False, 'active_ids': [self.group_pigs_id, group_bird_id]}) compose = mail_compose.browse(cr, uid, compose_id) @@ -531,12 +522,13 @@ class test_mail(TestMailMockups): def test_40_needaction(self): """ Tests for mail.message needaction. """ - cr, uid = self.cr, self.uid - group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) - group_pigs_demo = self.mail_group.browse(cr, self.user_demo, self.group_pigs_id) - user_admin = self.res_users.browse(cr, uid, uid) + cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs + user_demo = self.res_users.browse(cr, uid, self.user_demo_id) + group_pigs_demo = self.mail_group.browse(cr, self.user_demo_id, self.group_pigs_id) + na_admin_base = self.mail_message._needaction_count(cr, uid, domain=[]) + na_demo_base = self.mail_message._needaction_count(cr, user_demo.id, domain=[]) - # Demo values: check unread notification = needaction on mail.message + # Test: number of unread notification = needaction on mail.message notif_ids = self.mail_notification.search(cr, uid, [ ('partner_id', '=', user_admin.partner_id.id), ('read', '=', False) @@ -544,36 +536,32 @@ class test_mail(TestMailMockups): na_count = self.mail_message._needaction_count(cr, uid, domain=[]) self.assertEqual(len(notif_ids), na_count, 'unread notifications count does not match needaction count') - na_count1 = self.mail_message._needaction_count(cr, uid, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)]) - # Post 2 message on group_pigs as admin, 3 messages as demo user + # Do: post 2 message on group_pigs as admin, 3 messages as demo user for dummy in range(2): group_pigs.message_post(body='My Body', subtype='mt_comment') for dummy in range(3): group_pigs_demo.message_post(body='My Demo Body', subtype='mt_comment') - # Check there are 4 new needaction on mail.message + # Test: admin has 3 new notifications (from demo), and 3 new needaction notif_ids = self.mail_notification.search(cr, uid, [ ('partner_id', '=', user_admin.partner_id.id), ('read', '=', False) ]) - na_count = self.mail_message._needaction_count(cr, uid, domain=[]) - self.assertEqual(len(notif_ids), na_count, 'unread notifications count does not match needaction count') - - # Check there are 4 needaction on mail.message with particular domain - na_count = self.mail_message._needaction_count(cr, uid, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)]) + self.assertEqual(len(notif_ids), na_admin_base + 3, 'Admin should have 3 new unread notifications') + na_admin = self.mail_message._needaction_count(cr, uid, domain=[]) + na_admin_group = self.mail_message._needaction_count(cr, uid, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)]) + self.assertEqual(na_admin, na_admin_base + 3, 'Admin should have 3 new needaction') + self.assertEqual(na_admin_group, 3, 'Admin should have 3 needaction related to Pigs') + # Test: demo has 0 new notifications (not a follower, not receiving its own messages), and 0 new needaction notif_ids = self.mail_notification.search(cr, uid, [ - ('partner_id', '=', user_admin.partner_id.id), - ('read', '=', False), - ('message_id.model','=','mail.group'), - ('message_id.res_id','=',self.group_pigs_id) + ('partner_id', '=', user_demo.partner_id.id), + ('read', '=', False) ]) - self.assertEqual(len(notif_ids), na_count, 'posted message count does not match needaction count') - - na_count3 = self.mail_message._needaction_count(cr, self.user_demo, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)]) - self.assertEqual(na_count3-na_count1, 0, 'demo has 0 message: not a follower and do not follow his own messages') - - na_count2 = self.mail_message._needaction_count(cr, uid, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)]) - self.assertEqual(na_count2-na_count1, 3, 'admin has 3 messages: 0 from itself as they are marked as read, 3 from demo') + self.assertEqual(len(notif_ids), na_demo_base + 0, 'Demo should have 0 new unread notifications') + na_demo = self.mail_message._needaction_count(cr, user_demo.id, domain=[]) + na_demo_group = self.mail_message._needaction_count(cr, user_demo.id, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)]) + self.assertEqual(na_demo, na_demo_base + 0, 'Demo should have 0 new needaction') + self.assertEqual(na_demo_group, 0, 'Demo should have 0 needaction related to Pigs') def test_50_thread_parent_resolution(self): """Verify parent/child relationships are correctly established when processing incoming mails""" diff --git a/addons/mail/tests/test_mail_access_rights.py b/addons/mail/tests/test_mail_access_rights.py index 4d40c66fc81..544191205b8 100644 --- a/addons/mail/tests/test_mail_access_rights.py +++ b/addons/mail/tests/test_mail_access_rights.py @@ -102,53 +102,69 @@ class test_mail_access_rights(test_mail.TestMailMockups): """ Test mail_message search override about access rights. """ self.assertTrue(1 == 1, 'Test not implemented, do not replace by return True') - # def test_10_mail_flow_access_rights(self): - # """ Test a Chatter-looks alike flow. """ - # cr, uid = self.cr, self.uid - # partner_bert_id, partner_raoul_id = self.partner_bert_id, self.partner_raoul_id - # user_bert_id, user_raoul_id = self.user_bert_id, self.user_raoul_id + def test_10_mail_flow_access_rights(self): + """ Test a Chatter-looks alike flow. """ + cr, uid = self.cr, self.uid + mail_compose = self.registry('mail.compose.message') + partner_bert_id, partner_raoul_id = self.partner_bert_id, self.partner_raoul_id + user_bert_id, user_raoul_id = self.user_bert_id, self.user_raoul_id - # # Prepare groups: Pigs (employee), Jobs (public) - # self.mail_group.message_post(cr, uid, self.group_pigs_id, body='Message') - # self.group_jobs_id = self.mail_group.create(cr, uid, {'name': 'Jobs', 'public': 'public'}) + # Prepare groups: Pigs (employee), Jobs (public) + self.mail_group.message_post(cr, uid, self.group_pigs_id, body='Message') + self.group_jobs_id = self.mail_group.create(cr, uid, {'name': 'Jobs', 'public': 'public'}) - # # ---------------------------------------- - # # CASE1: Bert, without groups - # # ---------------------------------------- - # # Do: Bert creates a group, should crash because perm_create only for employees - # self.assertRaises(except_orm, - # self.mail_group.create, - # cr, user_bert_id, {'name': 'Bert\'s Group'}) - # # Do: Bert reads Jobs basic fields, ok because public = read access on the group - # self.mail_group.read(cr, user_bert_id, self.group_jobs_id, ['name', 'description']) - # # Do: Bert browse Pigs, ok (no direct browse of partners) - # self.mail_group.browse(cr, user_bert_id, self.group_jobs_id) - # # Do: Bert reads Jobs messages, ok because read access on the group => read access on its messages - # jobs_message_ids = self.mail_group.read(cr, user_bert_id, self.group_jobs_id, ['message_ids'])['message_ids'] - # self.mail_message.read(cr, user_bert_id, jobs_message_ids) - # # Do: Bert reads Jobs followers, ko because partner are accessible to employees or partner manager - # jobs_followers_ids = self.mail_group.read(cr, user_bert_id, self.group_jobs_id, ['message_follower_ids'])['message_follower_ids'] - # self.assertRaises(except_orm, - # self.res_partner.read, - # cr, user_bert_id, jobs_followers_ids) - # # Do: Bert comments Jobs, ko because no write access on the group and not in the followers - # self.assertRaises(except_orm, - # self.mail_group.message_post, - # cr, user_bert_id, self.group_jobs_id, body='I love Pigs') - # # Do: add Bert to jobs followers - # self.mail_group.message_subscribe(cr, uid, [self.group_jobs_id], [partner_bert_id]) - # # Do: Bert comments Jobs, ok because he is now in the followers - # self.mail_group.message_post(cr, user_bert_id, self.group_jobs_id, body='I love Pigs') + # ---------------------------------------- + # CASE1: Bert, without groups + # ---------------------------------------- + # Do: Bert creates a group, should crash because perm_create only for employees + self.assertRaises(except_orm, + self.mail_group.create, + cr, user_bert_id, {'name': 'Bert\'s Group'}) - # # Do: Bert reads Pigs, should crash because mail.group security=groups only for employee group - # self.assertRaises(except_orm, - # self.mail_group.read, - # cr, user_bert_id, self.group_pigs_id) + # Do: Bert reads Jobs basic fields, ok because public = read access on the group + self.mail_group.read(cr, user_bert_id, self.group_jobs_id, ['name', 'description']) + # Do: Bert browse Pigs, ok (no direct browse of partners) + self.mail_group.browse(cr, user_bert_id, self.group_jobs_id) + # Do: Bert reads Jobs messages, ok because read access on the group => read access on its messages + jobs_message_ids = self.mail_group.read(cr, user_bert_id, self.group_jobs_id, ['message_ids'])['message_ids'] + self.mail_message.read(cr, user_bert_id, jobs_message_ids) + # Do: Bert reads Jobs followers, ko because partner are accessible to employees or partner manager + jobs_followers_ids = self.mail_group.read(cr, user_bert_id, self.group_jobs_id, ['message_follower_ids'])['message_follower_ids'] + self.assertRaises(except_orm, + self.res_partner.read, + cr, user_bert_id, jobs_followers_ids) + # Do: Bert comments Jobs, ko because no write access on the group and not in the followers + self.assertRaises(except_orm, + self.mail_group.message_post, + cr, user_bert_id, self.group_jobs_id, body='I love Pigs') + # Do: add Bert to jobs followers + self.mail_group.message_subscribe(cr, uid, [self.group_jobs_id], [partner_bert_id]) + # Do: Bert comments Jobs, ok because he is now in the followers + self.mail_group.message_post(cr, user_bert_id, self.group_jobs_id, body='I love Pigs') - # # ---------------------------------------- - # # CASE1: Raoul, employee - # # ---------------------------------------- - # # Do: Bert read Pigs, ok because public - # self.mail_group.read(cr, user_raoul_id, self.group_pigs_id) - # # Do: Bert read Jobs, ok because group_public_id = employee - # self.mail_group.read(cr, user_raoul_id, self.group_jobs_id) + # Do: Bert reads Pigs, should crash because mail.group security=groups only for employee group + self.assertRaises(except_orm, + self.mail_group.read, + cr, user_bert_id, self.group_pigs_id) + + # Do: Bert create a mail.compose.message record, because he uses the wizard + compose_id = mail_compose.create(cr, user_bert_id, + {'subject': 'Subject', 'body_text': 'Body text', 'partner_ids': []}, + # {'subject': 'Subject', 'body_text': 'Body text', 'partner_ids': [(4, p_c_id), (4, p_d_id)]}, + {'default_composition_mode': 'comment', 'default_model': 'mail.group', 'default_res_id': self.group_jobs_id}) + mail_compose.send_mail(cr, user_bert_id, [compose_id]) + + self.user_demo_id = self.registry('ir.model.data').get_object_reference(self.cr, self.uid, 'base', 'user_demo')[1] + compose_id = mail_compose.create(cr, self.user_demo_id, + {'subject': 'Subject', 'body_text': 'Body text', 'partner_ids': []}, + # {'subject': 'Subject', 'body_text': 'Body text', 'partner_ids': [(4, p_c_id), (4, p_d_id)]}, + {'default_composition_mode': 'comment', 'default_model': 'mail.group', 'default_res_id': self.group_jobs_id}) + mail_compose.send_mail(cr, self.user_demo_id, [compose_id]) + + # ---------------------------------------- + # CASE2: Raoul, employee + # ---------------------------------------- + # Do: Bert read Pigs, ok because public + self.mail_group.read(cr, user_raoul_id, self.group_pigs_id) + # Do: Bert read Jobs, ok because group_public_id = employee + self.mail_group.read(cr, user_raoul_id, self.group_jobs_id) diff --git a/addons/mail/update.py b/addons/mail/update.py index 0e10ee0a7f1..9e35391bf52 100644 --- a/addons/mail/update.py +++ b/addons/mail/update.py @@ -41,6 +41,8 @@ def get_sys_logs(cr, uid): nbr_share_users = pool.get("res.users").search(cr, uid, [("share", "=", True)], count=True) nbr_active_share_users = pool.get("res.users").search(cr, uid, [("share", "=", True), ("date", ">=", limit_date_str)], count=True) user = pool.get("res.users").browse(cr, uid, uid) + + web_base_url = safe_eval(self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url', 'False')) msg = { "dbuuid": dbuuid, "nbr_users": nbr_users, @@ -51,6 +53,7 @@ def get_sys_logs(cr, uid): "db_create_date": db_create_date, "version": release.version, "language": user.lang, + "web_base_url": web_base_url, } msg.update(pool.get("res.company").read(cr,uid,[1],["name","email","phone"])[0]) diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 7d75c67b942..b68aae14521 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -81,11 +81,7 @@ class mail_compose_message(osv.TransientModel): elif composition_mode == 'comment' and model and res_id: vals = self.get_record_data(cr, uid, model, res_id, context=context) elif composition_mode == 'mass_mail' and model and active_ids: - if context.get('default_template_id'): - vals = self.pool.get('email.template').generate_email(cr, uid, context.get('default_template_id'), res_id, context=context) - vals.update({'content_subtype': 'html'}) - else: - vals = {'model': model, 'res_id': res_id, 'content_subtype': 'html'} + vals = {'model': model, 'res_id': res_id, 'content_subtype': 'html'} else: vals = {'model': model, 'res_id': res_id} if composition_mode: @@ -229,22 +225,13 @@ class mail_compose_message(osv.TransientModel): mass_mail_mode = wizard.composition_mode == 'mass_mail' active_model_pool = self.pool.get(wizard.model if wizard.model else 'mail.thread') - if wizard.content_subtype == 'html': - if not wizard.body: - return False - body = wizard.body - else: # wizard.content_subtype == 'plain': - if not wizard.body_text: - return False - body = '
%s' % tools.ustr(wizard.body_text or '') - # wizard works in batch mode: [res_id] or active_ids res_ids = active_ids if mass_mail_mode and wizard.model and active_ids else [wizard.res_id] for res_id in res_ids: # default values, according to the wizard options post_values = { 'subject': wizard.subject if wizard.content_subtype == 'html' else False, - 'body': body, + 'body': wizard.body if wizard.content_subtype == 'html' else '
%s' % tools.ustr(wizard.body_text), 'parent_id': wizard.parent_id and wizard.parent_id.id, 'partner_ids': [(4, partner.id) for partner in wizard.partner_ids], 'attachments': [(attach.datas_fname or attach.name, base64.b64decode(attach.datas)) for attach in wizard.attachment_ids], @@ -258,13 +245,13 @@ class mail_compose_message(osv.TransientModel): post_values['attachments'] += new_attachments post_values.update(email_dict) # post the message - id=active_model_pool.message_post(cr, uid, [res_id], type='comment', subtype='mt_comment', context=context, **post_values) + active_model_pool.message_post(cr, uid, [res_id], type='comment', subtype='mt_comment', context=context, **post_values) # post process: update attachments, because id is not necessarily known when adding attachments in Chatter # self.pool.get('ir.attachment').write(cr, uid, [attach.id for attach in wizard.attachment_ids], { # 'res_id': wizard.id, 'res_model': wizard.model or False}, context=context) - - return {'type': 'ir.actions.act_window_close', 'res_model':'mail.compose.message', 'id': id} + + return {'type': 'ir.actions.act_window_close'} def render_message(self, cr, uid, wizard, res_id, context=None): """ Generate an email from the template for given (wizard.model, res_id) diff --git a/addons/mail/wizard/mail_compose_message_view.xml b/addons/mail/wizard/mail_compose_message_view.xml index 7329992f8ed..ce86e0bacfd 100644 --- a/addons/mail/wizard/mail_compose_message_view.xml +++ b/addons/mail/wizard/mail_compose_message_view.xml @@ -6,17 +6,19 @@