[FIX] mail: subscribe to threads before sending first message

Users subscribed to creation of records (new leads in a sales team, new
tasks in a project, etc.) are never notified. The reason is that users
were subscribed after the record creation notification.

Introduced in 43915a8721
Closes #8723
This commit is contained in:
Jairo Llopis 2015-09-28 17:04:32 +02:00 committed by Nicolas Martinelli
parent d65f251d12
commit ffa28488be
1 changed files with 7 additions and 7 deletions

View File

@ -387,6 +387,13 @@ class mail_thread(osv.AbstractModel):
name = ir_model_pool.read(cr, uid, ids, ['name'], context=context)[0]['name']
self.message_post(cr, uid, thread_id, body=_('%s created') % name, context=context)
# auto_subscribe: take values and defaults into account
create_values = dict(values)
for key, val in context.iteritems():
if key.startswith('default_') and key[8:] not in create_values:
create_values[key[8:]] = val
self.message_auto_subscribe(cr, uid, [thread_id], create_values.keys(), context=context, values=create_values)
# track values
track_ctx = dict(context)
if 'lang' not in track_ctx:
@ -397,13 +404,6 @@ class mail_thread(osv.AbstractModel):
initial_values = {thread_id: dict.fromkeys(tracked_fields, False)}
self.message_track(cr, uid, [thread_id], tracked_fields, initial_values, context=track_ctx)
# auto_subscribe: take values and defaults into account
create_values = dict(values)
for key, val in context.iteritems():
if key.startswith('default_') and key[8:] not in create_values:
create_values[key[8:]] = val
self.message_auto_subscribe(cr, uid, [thread_id], create_values.keys(), context=context, values=create_values)
return thread_id
def write(self, cr, uid, ids, values, context=None):