From 86200b4d9ca514a1ea472cb409ea4c20b84bfde7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Dec 2012 18:15:01 +0100 Subject: [PATCH] [DOC] [IMP] mail_thread: updated documented the few magic context keys, mail_notify_noemail, mail_create_nosubscribe and mail_create_nolog. bzr revid: tde@openerp.com-20121219171501-5ndw7aawi8kvttql --- addons/mail/doc/mail_thread.rst | 10 ++++++++++ addons/mail/mail_followers.py | 4 ++-- addons/mail/mail_thread.py | 4 ++-- addons/mail/tests/test_mail_base.py | 2 +- addons/mail/tests/test_mail_features.py | 4 ++-- addons/portal_crm/contact.py | 4 ++-- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/addons/mail/doc/mail_thread.rst b/addons/mail/doc/mail_thread.rst index 41ea014b06c..c0f603e1a8d 100644 --- a/addons/mail/doc/mail_thread.rst +++ b/addons/mail/doc/mail_thread.rst @@ -40,3 +40,13 @@ OpenChatter updates the res.users class: - it adds a preference about sending emails when receiving a notification - make a new user follow itself automatically - create a welcome message when creating a new user, to make his arrival in OpenERP more friendly + + +Misc magic context keys ++++++++++++++++++++++++ + + - mail_create_nosubscribe: when creating a new record that inherit from mail_thread, + do not subscribe the creator to the document followers + - mail_create_nolog: do not log creation message + - mail_notify_noemail: do not send email notifications; partners to notify are + notified, i.e. a mail_notification is created, but no email is actually send diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py index e0d07e8c36c..5769dfe554b 100644 --- a/addons/mail/mail_followers.py +++ b/addons/mail/mail_followers.py @@ -114,8 +114,8 @@ class mail_notification(osv.Model): """ Send by email the notification depending on the user preferences """ if context is None: context = {} - # mail_noemail (do not send email) or no partner_ids: do not send, return - if context.get('mail_noemail'): + # mail_notify_noemail (do not send email) or no partner_ids: do not send, return + if context.get('mail_notify_noemail'): return True # browse as SUPERUSER_ID because of access to res_partner not necessarily allowed msg = self.pool.get('mail.message').browse(cr, SUPERUSER_ID, msg_id, context=context) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 94011163574..3503910bb18 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -241,12 +241,12 @@ class mail_thread(osv.AbstractModel): thread_id = super(mail_thread, self).create(cr, uid, values, context=context) # subscribe uid unless asked not to - if not context.get('mail_nosubscribe'): + if not context.get('mail_create_nosubscribe'): self.message_subscribe_users(cr, uid, [thread_id], [uid], context=context) self.message_subscribe_from_parent(cr, uid, [thread_id], values.keys(), context=context) # automatic logging unless asked not to (mainly for various testing purpose) - if not context.get('mail_nolog'): + if not context.get('mail_create_nolog'): self.message_post(cr, uid, thread_id, body='Document created.', context=context) return thread_id diff --git a/addons/mail/tests/test_mail_base.py b/addons/mail/tests/test_mail_base.py index ca705559158..527375644df 100644 --- a/addons/mail/tests/test_mail_base.py +++ b/addons/mail/tests/test_mail_base.py @@ -83,7 +83,7 @@ class TestMailBase(common.TransactionCase): # Test 'pigs' group to use through the various tests self.group_pigs_id = self.mail_group.create(cr, uid, {'name': 'Pigs', 'description': 'Fans of Pigs, unite !'}, - {'mail_nolog': True}) + {'mail_create_nolog': True}) self.group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) def tearDown(self): diff --git a/addons/mail/tests/test_mail_features.py b/addons/mail/tests/test_mail_features.py index 600f84c0ebb..e6b61388b4e 100644 --- a/addons/mail/tests/test_mail_features.py +++ b/addons/mail/tests/test_mail_features.py @@ -204,7 +204,7 @@ class test_mail(TestMailBase): # 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'}, {'mail_nolog': True}) + {'name': 'Dummy group'}, {'mail_create_nolog': True}) self.mail_followers.create(cr, uid, {'res_model': 'mail.thread', 'res_id': self.group_pigs_id, 'partner_id': partner_bert_id}) self.mail_followers.create(cr, uid, @@ -443,7 +443,7 @@ class test_mail(TestMailBase): 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'}) - group_bird_id = self.mail_group.create(cr, uid, {'name': 'Bird', 'description': 'Bird resistance'}, {'mail_nolog': True}) + group_bird_id = self.mail_group.create(cr, uid, {'name': 'Bird', 'description': 'Bird resistance'}, {'mail_create_nolog': True}) group_bird = self.mail_group.browse(cr, uid, group_bird_id) # Mail data diff --git a/addons/portal_crm/contact.py b/addons/portal_crm/contact.py index 1cc10344d67..fa1bb240a7b 100644 --- a/addons/portal_crm/contact.py +++ b/addons/portal_crm/contact.py @@ -101,11 +101,11 @@ class crm_contact_us(osv.TransientModel): """ Create an empty record in the contact table. Since the 'name' field is mandatory, give an empty string to avoid an integrity error. - Pass mail_nosubscribe key in context because otherwise the inheritance + Pass mail_create_nosubscribe key in context because otherwise the inheritance leads to a message_subscribe_user, that triggers access right issues. """ empty_values = dict((k, False) if k != 'name' else (k, '') for k, v in values.iteritems()) - return super(crm_contact_us, self).create(cr, uid, empty_values, {'mail_nosubscribe': True}) + return super(crm_contact_us, self).create(cr, uid, empty_values, {'mail_create_nosubscribe': True}) def submit(self, cr, uid, ids, context=None): """ When the form is submitted, redirect the user to a "Thanks" message """