[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
This commit is contained in:
Thibault Delavallée 2012-12-19 18:15:01 +01:00
parent 3dadb7b062
commit 86200b4d9c
6 changed files with 19 additions and 9 deletions

View File

@ -40,3 +40,13 @@ OpenChatter updates the res.users class:
- it adds a preference about sending emails when receiving a notification - it adds a preference about sending emails when receiving a notification
- make a new user follow itself automatically - make a new user follow itself automatically
- create a welcome message when creating a new user, to make his arrival in OpenERP more friendly - 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

View File

@ -114,8 +114,8 @@ class mail_notification(osv.Model):
""" Send by email the notification depending on the user preferences """ """ Send by email the notification depending on the user preferences """
if context is None: if context is None:
context = {} context = {}
# mail_noemail (do not send email) or no partner_ids: do not send, return # mail_notify_noemail (do not send email) or no partner_ids: do not send, return
if context.get('mail_noemail'): if context.get('mail_notify_noemail'):
return True return True
# browse as SUPERUSER_ID because of access to res_partner not necessarily allowed # 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) msg = self.pool.get('mail.message').browse(cr, SUPERUSER_ID, msg_id, context=context)

View File

@ -241,12 +241,12 @@ class mail_thread(osv.AbstractModel):
thread_id = super(mail_thread, self).create(cr, uid, values, context=context) thread_id = super(mail_thread, self).create(cr, uid, values, context=context)
# subscribe uid unless asked not to # 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_users(cr, uid, [thread_id], [uid], context=context)
self.message_subscribe_from_parent(cr, uid, [thread_id], values.keys(), 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) # 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 <b>created</b>.', context=context) self.message_post(cr, uid, thread_id, body='Document <b>created</b>.', context=context)
return thread_id return thread_id

View File

@ -83,7 +83,7 @@ class TestMailBase(common.TransactionCase):
# Test 'pigs' group to use through the various tests # Test 'pigs' group to use through the various tests
self.group_pigs_id = self.mail_group.create(cr, uid, self.group_pigs_id = self.mail_group.create(cr, uid,
{'name': 'Pigs', 'description': 'Fans of Pigs, unite !'}, {'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) self.group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id)
def tearDown(self): def tearDown(self):

View File

@ -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 # 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, 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, self.mail_followers.create(cr, uid,
{'res_model': 'mail.thread', 'res_id': self.group_pigs_id, 'partner_id': partner_bert_id}) {'res_model': 'mail.thread', 'res_id': self.group_pigs_id, 'partner_id': partner_bert_id})
self.mail_followers.create(cr, uid, 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 cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs
mail_compose = self.registry('mail.compose.message') mail_compose = self.registry('mail.compose.message')
self.res_users.write(cr, uid, [uid], {'signature': 'Admin', 'email': 'a@a'}) 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) group_bird = self.mail_group.browse(cr, uid, group_bird_id)
# Mail data # Mail data

View File

@ -101,11 +101,11 @@ class crm_contact_us(osv.TransientModel):
""" """
Create an empty record in the contact table. Create an empty record in the contact table.
Since the 'name' field is mandatory, give an empty string to avoid an integrity error. 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. 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()) 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): def submit(self, cr, uid, ids, context=None):
""" When the form is submitted, redirect the user to a "Thanks" message """ """ When the form is submitted, redirect the user to a "Thanks" message """