From 587f3ff41da36c332e94c2552e61470e4199d717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 10:10:16 +0200 Subject: [ADD] mail.thread: added boolean field for read/unread. bzr revid: tde@openerp.com-20120604081016-3x21acf0zccgeyhv --- addons/mail/mail_thread.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b1b6c68e4cc..b821edb5165 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -72,6 +72,8 @@ class mail_thread(osv.osv): _columns = { 'message_ids': fields.function(_get_message_ids, method=True, type='one2many', obj='mail.message', string='Temp messages', _fields_id = 'res_id'), + 'thread_read': fields.boolean('Read', + help="When checked, new messages require your attention."), } #------------------------------------------------------ -- cgit v1.2.3 From fcf07cc65f9dfe618c38ccf9e107c2ab85d539a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 11:33:24 +0200 Subject: [IMP] mail_thread: thread_read -> thread_is_read; added API methods to mark read/unread; small code cleaning. bzr revid: tde@openerp.com-20120604093324-x3mtl4lu4883lqz0 --- addons/mail/mail_thread.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b821edb5165..3deb7f25769 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -71,8 +71,9 @@ class mail_thread(osv.osv): # OpenChatter: message_ids is a dummy field that should not be used _columns = { 'message_ids': fields.function(_get_message_ids, method=True, - type='one2many', obj='mail.message', string='Temp messages', _fields_id = 'res_id'), - 'thread_read': fields.boolean('Read', + type='one2many', obj='mail.message', string='Temp messages', _fields_id = 'res_id', + help="Functional field holding messages related to the current document."), + 'thread_is_read': fields.boolean('Read', help="When checked, new messages require your attention."), } @@ -81,10 +82,11 @@ class mail_thread(osv.osv): #------------------------------------------------------ def create(self, cr, uid, vals, context=None): - """Automatically subscribe the creator""" - thread_id = super(mail_thread, self).create(cr, uid, vals, context=context); - self.message_subscribe(cr, uid, [thread_id], [uid], context=context) - return thread_id; + """Automatically subscribe the creator """ + thread_id = super(mail_thread, self).create(cr, uid, vals, context=context) + if thread_id: + self.message_subscribe(cr, uid, [thread_id], [uid], context=context) + return thread_id def write(self, cr, uid, ids, vals, context=None): """Automatically subscribe the writer""" @@ -103,8 +105,6 @@ class mail_thread(osv.osv): a foreign key with a 'cascade' ondelete attribute. Notifications will be deleted with messages """ - if context is None: - context = {} subscr_obj = self.pool.get('mail.subscription') msg_obj = self.pool.get('mail.message') # delete subscriptions @@ -121,13 +121,14 @@ class mail_thread(osv.osv): #------------------------------------------------------ def message_create(self, cr, uid, thread_id, vals, context=None): - """OpenSocial: wrapper of mail.message create method + """ OpenChatter: wrapper of mail.message create method - creates the mail.message - automatically subscribe the message writer - push the message to subscribed users """ if context is None: context = {} + message_obj = self.pool.get('mail.message') subscription_obj = self.pool.get('mail.subscription') notification_obj = self.pool.get('mail.notification') @@ -793,4 +794,15 @@ class mail_thread(osv.osv): to_del_notif_ids = notif_obj.search(cr, uid, ['&', ('user_id', '=', uid), ('message_id', 'in', notif_msg_ids)], context=context) return notif_obj.unlink(cr, uid, to_del_notif_ids, context=context) + #------------------------------------------------------ + # Thread_state + #------------------------------------------------------ + + def message_mark_as_read(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'thread_is_read': True}, context=context) + + def message_mark_as_unread(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'thread_is_read': False}, context=context) + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From 445b690488e3aeb7ddf87c3692008b033c54496c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 12:24:35 +0200 Subject: [IMP] mail_thread: message_process now automatically set the thread as unread. bzr revid: tde@openerp.com-20120604102435-hcdo3i6oqdhu6j8j --- addons/mail/mail_thread.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 3deb7f25769..d52804308a3 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -535,6 +535,8 @@ class mail_thread(osv.osv): res_id = create_record(msg) #To forward the email to other followers self.message_forward(cr, uid, model, [res_id], msg_txt, context=context) + # Set as Unread + self.message_mark_as_unreadcr, uid, [res_id], context=context) return res_id def message_new(self, cr, uid, msg_dict, custom_values=None, context=None): -- cgit v1.2.3 From 0bf38a496c6bd4c8f84c0881b63ecb9f91441e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 12:27:51 +0200 Subject: [FIX] mail_thread: added forgotten '\('. bzr revid: tde@openerp.com-20120604102751-b61hsx03guhpbye0 --- addons/mail/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index d52804308a3..bfe0bc9559a 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -536,7 +536,7 @@ class mail_thread(osv.osv): #To forward the email to other followers self.message_forward(cr, uid, model, [res_id], msg_txt, context=context) # Set as Unread - self.message_mark_as_unreadcr, uid, [res_id], context=context) + self.message_mark_as_unread(cr, uid, [res_id], context=context) return res_id def message_new(self, cr, uid, msg_dict, custom_values=None, context=None): -- cgit v1.2.3 From bb5f7d384d574461fc031de1cf41181a5bd6a90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 16:12:54 +0200 Subject: [IMP] crm_lead, crm_claim, crm_fundraising, crm_helpdesk, hr_recruitment, project_issue, project_mailgate: cleaned and updated message_new and message_update to have a cleaner mailgate. Deleted references to state update. bzr revid: tde@openerp.com-20120604141254-4m2tnzwi88w8h2aj --- addons/mail/mail_thread.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index bfe0bc9559a..91ae096b70e 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -571,29 +571,34 @@ class mail_thread(osv.osv): fields = model_pool.fields_get(cr, uid, context=context) data = model_pool.default_get(cr, uid, fields, context=context) if 'name' in fields and not data.get('name'): - data['name'] = msg_dict.get('from','') + data['name'] = msg_dict.get('from', '') if custom_values and isinstance(custom_values, dict): data.update(custom_values) res_id = model_pool.create(cr, uid, data, context=context) self.message_append_dict(cr, uid, [res_id], msg_dict, context=context) return res_id - def message_update(self, cr, uid, ids, msg_dict, vals={}, default_act=None, context=None): - """Called by ``message_process`` when a new message is received - for an existing thread. The default behavior is to create a - new mail.message in the given thread (by calling - ``message_append_dict``) - Additional behavior may be implemented by overriding this - method. + def message_update(self, cr, uid, ids, msg_dict, update_vals=None, context=None): + """ Called by ``message_process`` when a new message is received + for an existing thread. The default behavior is to create a + new mail.message in the given thread (by calling + ``message_append_dict``) + Additional behavior may be implemented by overriding this + method. - :param dict msg_dict: a map containing the email details and + :param dict msg_dict: a map containing the email details and attachments. See ``message_process`` and ``mail.message.parse()`` for details. - :param dict context: if a ``thread_model`` value is present + :param dict vals: a dict containing values to update records + given their ids; if the dict is None or is + void, no write operation is performed. + :param dict context: if a ``thread_model`` value is present in the context, its value will be used to determine the model of the thread to update (instead of the current model). """ + if update_vals: + self.write(cr, uid, ids, update_vals, context=context) return self.message_append_dict(cr, uid, ids, msg_dict, context=context) def message_thread_followers(self, cr, uid, ids, context=None): @@ -806,5 +811,13 @@ class mail_thread(osv.osv): def message_mark_as_unread(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'thread_is_read': False}, context=context) + def get_needaction_user_ids(self, cr, uid, ids, context=None): + result = dict.fromkeys(ids, []) + for obj in self.browse(cr, uid, ids, context=context): + if obj.thread_is_read == False and hasattr(obj, 'user_id') and obj.user_id: + result[obj.id] = [obj.user_id.id] + print 'needaction: %s' % (str(result)) + return result + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From b1b960a9a42cbe196be23a30d22a8b4891abf782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 17:27:06 +0200 Subject: [FIX] mail_thread: thread_is_read -> message_thread_read: propagated change; removed dead code; fixed a call on a wrong model.L bzr revid: tde@openerp.com-20120604152706-z58wbwnmnu8z8mvd --- addons/mail/mail_thread.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 91ae096b70e..59fd829b009 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -34,7 +34,7 @@ import xmlrpclib _logger = logging.getLogger(__name__) -class mail_thread(osv.osv): +class mail_thread(osv.Model): '''Mixin model, meant to be inherited by any model that needs to act as a discussion topic on which messages can be attached. Public methods are prefixed with ``message_`` in order to avoid @@ -73,9 +73,13 @@ class mail_thread(osv.osv): 'message_ids': fields.function(_get_message_ids, method=True, type='one2many', obj='mail.message', string='Temp messages', _fields_id = 'res_id', help="Functional field holding messages related to the current document."), - 'thread_is_read': fields.boolean('Read', + 'message_thread_read': fields.boolean('Read', help="When checked, new messages require your attention."), } + + _defaults = { + 'message_thread_read': True, + } #------------------------------------------------------ # Automatic subscription when creating/reading @@ -524,7 +528,7 @@ class mail_thread(osv.osv): if res_id: res_id = res_id.group(1) if res_id: - res_id = int(res_id) + res_id = res_id if model_pool.exists(cr, uid, res_id): if hasattr(model_pool, 'message_update'): model_pool.message_update(cr, uid, [res_id], msg, {}, context=context) @@ -532,11 +536,11 @@ class mail_thread(osv.osv): # referenced thread was not found, we'll have to create a new one res_id = False if not res_id: - res_id = create_record(msg) - #To forward the email to other followers + res_id = int(create_record(msg)) + # To forward the email to other followers self.message_forward(cr, uid, model, [res_id], msg_txt, context=context) # Set as Unread - self.message_mark_as_unread(cr, uid, [res_id], context=context) + model_pool.message_mark_as_unread(cr, uid, [res_id], context=context) return res_id def message_new(self, cr, uid, msg_dict, custom_values=None, context=None): @@ -806,18 +810,10 @@ class mail_thread(osv.osv): #------------------------------------------------------ def message_mark_as_read(self, cr, uid, ids, context=None): - return self.write(cr, uid, ids, {'thread_is_read': True}, context=context) + return self.write(cr, uid, ids, {'message_thread_read': True}, context=context) def message_mark_as_unread(self, cr, uid, ids, context=None): - return self.write(cr, uid, ids, {'thread_is_read': False}, context=context) - - def get_needaction_user_ids(self, cr, uid, ids, context=None): - result = dict.fromkeys(ids, []) - for obj in self.browse(cr, uid, ids, context=context): - if obj.thread_is_read == False and hasattr(obj, 'user_id') and obj.user_id: - result[obj.id] = [obj.user_id.id] - print 'needaction: %s' % (str(result)) - return result + return self.write(cr, uid, ids, {'message_thread_read': False}, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From 6aa0ca7a7e2f03edcd614cfa48831f67f83d58d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 5 Jun 2012 14:22:21 +0200 Subject: [IMP] mail_thread: cleaned message_get_subscribers and related methods; propagated change so that project_issue, mrp, crm_lead, project, project_task, hr_recruitment and hr_holidays now cleanly override message_get_subscribers. bzr revid: tde@openerp.com-20120605122221-nvxfxfcx5o82vkvx --- addons/mail/mail_thread.py | 55 +++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 15 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 59fd829b009..b77957cde5e 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -751,51 +751,76 @@ class mail_thread(osv.Model): # Subscription mechanism #------------------------------------------------------ - def message_get_subscribers_ids(self, cr, uid, ids, context=None): + def message_get_subscribers(self, cr, uid, ids, context=None): + """ Returns the current document followers. Basically this method + checks in mail.subscription for entries with matching res_model, + res_id. + + :param get_ids: if set to True, return the ids of users; if set + to False, returns the result of a read in res.users + """ subscr_obj = self.pool.get('mail.subscription') subscr_ids = subscr_obj.search(cr, uid, ['&', ('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) - subs = subscr_obj.read(cr, uid, subscr_ids, context=context) - return [sub['user_id'][0] for sub in subs] + return [sub['user_id'][0] for sub in subscr_obj.read(cr, uid, subscr_ids, ['user_id'], context=context)] - def message_get_subscribers(self, cr, uid, ids, context=None): - user_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context) - users = self.pool.get('res.users').read(cr, uid, user_ids, fields=['id', 'name', 'avatar'], context=context) - return users + def message_read_subscribers(self, cr, uid, ids, fields=['id', 'name', 'avatar'], context=None): + """ Returns the current document followers as a read result. Used + mainly for Chatter having only one method to call to have + details about users. + """ + user_ids = self.message_get_subscribers(cr, uid, ids, context=context) + return self.pool.get('res.users').read(cr, uid, user_ids, fields=fields, context=context) def message_is_subscriber(self, cr, uid, ids, user_id = None, context=None): - users = self.message_get_subscribers(cr, uid, ids, context=context) + """ Check if uid or user_id (if set) is a subscriber to the current + document. + + :param user_id: if set, check is done on user_id; if not set + check is done on uid + """ sub_user_id = uid if user_id is None else user_id - if sub_user_id in [user['id'] for user in users]: + if sub_user_id in self.message_get_subscribers(cr, uid, ids, context=context): return True return False def message_subscribe(self, cr, uid, ids, user_ids = None, context=None): + """ Subscribe the user (or user_ids) to the current document. + + :param user_ids: a list of user_ids; if not set, subscribe + uid instead + """ subscription_obj = self.pool.get('mail.subscription') to_subscribe_uids = [uid] if user_ids is None else user_ids create_ids = [] for id in ids: + already_subscribed_user_ids = self.message_get_subscribers(cr, uid, [id], context=context) for user_id in to_subscribe_uids: - if self.message_is_subscriber(cr, uid, [id], user_id=user_id, context=context): continue + if user_id in already_subscribed_user_ids: continue create_ids.append(subscription_obj.create(cr, uid, {'res_model': self._name, 'res_id': id, 'user_id': user_id}, context=context)) return create_ids def message_unsubscribe(self, cr, uid, ids, user_ids = None, context=None): - if not user_ids and not uid in self.message_get_subscribers_ids(cr, uid, ids, context=context): + """ Unsubscribe the user (or user_ids) from the current document. + + :param user_ids: a list of user_ids; if not set, subscribe + uid instead + """ + # Trying to unsubscribe somebody not in subscribers: returns False + # if special management is needed; allows to know that an automatically + # subscribed user tries to unsubscribe and allows to warn him + if not user_ids and not uid in self.message_get_subscribers(cr, uid, ids, context=context): return False subscription_obj = self.pool.get('mail.subscription') to_unsubscribe_uids = [uid] if user_ids is None else user_ids to_delete_sub_ids = subscription_obj.search(cr, uid, ['&', '&', ('res_model', '=', self._name), ('res_id', 'in', ids), ('user_id', 'in', to_unsubscribe_uids)], context=context) - subscription_obj.unlink(cr, uid, to_delete_sub_ids, context=context) - return True + return subscription_obj.unlink(cr, uid, to_delete_sub_ids, context=context) #------------------------------------------------------ # Notification API #------------------------------------------------------ def message_remove_pushed_notifications(self, cr, uid, ids, msg_ids, remove_childs=True, context=None): - if context is None: - context = {} notif_obj = self.pool.get('mail.notification') msg_obj = self.pool.get('mail.message') if remove_childs: -- cgit v1.2.3 From 0f3a6c82e9d2754cae02e8702b6c2936e9838bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 5 Jun 2012 14:40:38 +0200 Subject: [FIX] mail_thread: fixed error due to a small API change in message_get_subscribers. bzr revid: tde@openerp.com-20120605124038-2nf3xvl820k85hig --- addons/mail/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b77957cde5e..b1baf347ca2 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -188,7 +188,7 @@ class mail_thread(osv.Model): body = new_msg_vals.get('body_html', '') if new_msg_vals.get('subtype', 'plain') == 'html' else new_msg_vals.get('body_text', '') for thread_id in thread_ids: # add subscribers - notif_user_ids += [user['id'] for user in self.message_get_subscribers(cr, uid, [thread_id], context=context)] + notif_user_ids += self.message_get_subscribers(cr, uid, [thread_id], context=context) # add users requested via parsing message (@login) notif_user_ids += self.message_parse_users(cr, uid, [thread_id], body, context=context) # add users requested to perform an action (need_action mechanism) -- cgit v1.2.3 From de2e979212af5902fce8999bf9517dcee586ab78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 7 Jun 2012 17:17:53 +0200 Subject: [ADD] mail module: added an update of ir_needaction model, to include the message_thread_read field in need_action. This will allow to remove most of the needaction definitions through various modules. bzr revid: tde@openerp.com-20120607151753-j3znrs1jy5tx4xoh --- addons/mail/mail_thread.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b1baf347ca2..d52c910cbaa 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -170,6 +170,9 @@ class mail_thread(osv.Model): # create message msg_id = message_obj.create(cr, uid, vals, context=context) + # Set as unread if writer is not the document responsible + #model_pool.message_mark_as_unread(cr, uid, [res_id], context=context) + # special: if install mode, do not push demo data if context.get('install_mode', False): return True @@ -539,8 +542,6 @@ class mail_thread(osv.Model): res_id = int(create_record(msg)) # To forward the email to other followers self.message_forward(cr, uid, model, [res_id], msg_txt, context=context) - # Set as Unread - model_pool.message_mark_as_unread(cr, uid, [res_id], context=context) return res_id def message_new(self, cr, uid, msg_dict, custom_values=None, context=None): @@ -833,12 +834,36 @@ class mail_thread(osv.Model): #------------------------------------------------------ # Thread_state #------------------------------------------------------ - + def message_mark_as_read(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'message_thread_read': True}, context=context) + def message_create_mark_as_unread(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): + if hasattr(obj, 'user_id') and (not obj.user_id or (obj.user_id and obj.user_id.id != uid)): + self.mark_as_unread(cr, uid, [obj.id], context=None) + def message_mark_as_unread(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'message_thread_read': False}, context=context) +class ir_needaction_mixin(osv.Model): + """ Update of res.users class + - add a preference about sending emails about notificatoins + - make a new user follow itself + """ + _name = 'ir.needaction_mixin' + _inherit = ['ir.needaction_mixin'] + + def get_needaction_user_ids(self, cr, uid, ids, context=None): + """ Returns the user_ids that have to perform an action + :return: dict { record_id: [user_ids], } + """ + result = super(ir_needaction_mixin, self).get_needaction_user_ids(cr, uid, ids, context=context) + for obj in self.browse(cr, uid, ids, context=context): + if obj.message_thread_read == False and obj.user_id: + result[obj.id].add(obj.user_id.id) + return result + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From da9eeeec571ed0dd2c91b79eb85e155a0c100439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 8 Jun 2012 12:19:01 +0200 Subject: [REM] mail_thread: removed duplicated code. bzr revid: tde@openerp.com-20120608101901-6cs8w7ebiq19c662 --- addons/mail/mail_thread.py | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index d52c910cbaa..3d3f702a76c 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -847,23 +847,4 @@ class mail_thread(osv.Model): return self.write(cr, uid, ids, {'message_thread_read': False}, context=context) -class ir_needaction_mixin(osv.Model): - """ Update of res.users class - - add a preference about sending emails about notificatoins - - make a new user follow itself - """ - _name = 'ir.needaction_mixin' - _inherit = ['ir.needaction_mixin'] - - def get_needaction_user_ids(self, cr, uid, ids, context=None): - """ Returns the user_ids that have to perform an action - :return: dict { record_id: [user_ids], } - """ - result = super(ir_needaction_mixin, self).get_needaction_user_ids(cr, uid, ids, context=context) - for obj in self.browse(cr, uid, ids, context=context): - if obj.message_thread_read == False and obj.user_id: - result[obj.id].add(obj.user_id.id) - return result - - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From 02719b328f707d1e9a5b5b937a142f8160710205 Mon Sep 17 00:00:00 2001 From: "ara@tinyerp.com" <> Date: Wed, 13 Jun 2012 11:53:28 +0530 Subject: [FIX] fixe serevr log of project and producyt bzr revid: ara@tinyerp.com-20120613062328-yayadrc2hx2xuwva --- addons/mail/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b1b6c68e4cc..5e2cacbc4fd 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -294,7 +294,7 @@ class mail_thread(osv.osv): } to_attach.append(ir_attachment.create(cr, uid, data_attach, context=context)) - partner_id = hasattr(thread, 'partner_id') and (thread.partner_id and thread.partner_id.id or False) or False + partner_id = ('partner_id' in thread._columns.keys()) and (thread.partner_id and thread.partner_id.id or False) or False if not partner_id and thread._name == 'res.partner': partner_id = thread.id data = { -- cgit v1.2.3 From dc1edf44be5593f9048f442a8aec68ae5250d953 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Thu, 14 Jun 2012 12:09:22 +0200 Subject: [IMP] project: implemented the privacy/visibility record rule in a cleaner way + some cleanup and bug fixing related to contract management bzr revid: qdp-launchpad@openerp.com-20120614100922-5g29ui88nhqojon2 --- addons/mail/mail_thread.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b1b6c68e4cc..5e025c4b5f8 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -68,9 +68,14 @@ class mail_thread(osv.osv): res[id] = self.message_load_ids(cr, uid, [id], context=context) return res + def _search_message_ids(self, cr, uid, obj, name, args, context=None): + msg_obj = self.pool.get('mail.message') + msg_ids = msg_obj.search(cr, uid, ['&', ('res_id', 'in', args[0][2]), ('model', '=', self._name)], context=context) + return [('id', 'in', msg_ids)] + # OpenChatter: message_ids is a dummy field that should not be used _columns = { - 'message_ids': fields.function(_get_message_ids, method=True, + 'message_ids': fields.function(_get_message_ids, method=True, fnct_search=_search_message_ids, type='one2many', obj='mail.message', string='Temp messages', _fields_id = 'res_id'), } -- cgit v1.2.3 From c98b9d625eac02cd9dab1a1cdd145b9f0eff27fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 21 Jun 2012 10:40:35 +0200 Subject: [REF] mail_thread: renamed message_thread_read -> message_state bzr revid: tde@openerp.com-20120621084035-q3h7qij88l7lk912 --- addons/mail/mail_thread.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 3d3f702a76c..c01eed42e31 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -73,12 +73,12 @@ class mail_thread(osv.Model): 'message_ids': fields.function(_get_message_ids, method=True, type='one2many', obj='mail.message', string='Temp messages', _fields_id = 'res_id', help="Functional field holding messages related to the current document."), - 'message_thread_read': fields.boolean('Read', + 'message_state': fields.boolean('Read', help="When checked, new messages require your attention."), } _defaults = { - 'message_thread_read': True, + 'message_state': True, } #------------------------------------------------------ @@ -836,7 +836,7 @@ class mail_thread(osv.Model): #------------------------------------------------------ def message_mark_as_read(self, cr, uid, ids, context=None): - return self.write(cr, uid, ids, {'message_thread_read': True}, context=context) + return self.write(cr, uid, ids, {'message_state': True}, context=context) def message_create_mark_as_unread(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -844,7 +844,7 @@ class mail_thread(osv.Model): self.mark_as_unread(cr, uid, [obj.id], context=None) def message_mark_as_unread(self, cr, uid, ids, context=None): - return self.write(cr, uid, ids, {'message_thread_read': False}, context=context) + return self.write(cr, uid, ids, {'message_state': False}, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From a9a9cef9f25dad094a41b5e2e6ff2767801783f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 21 Jun 2012 11:37:55 +0200 Subject: [IMP] mail_thread: re-added set as unread when a new message arrives; un mesage_unsubscribe, check of 'eixsting' subscription is based on subscriber definition form mail.thread (i.e. present in mail.subscription table). bzr revid: tde@openerp.com-20120621093755-uooakb80twjskyd2 --- addons/mail/mail_thread.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index c01eed42e31..fb6d3e8f121 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -121,7 +121,7 @@ class mail_thread(osv.Model): return super(mail_thread, self).unlink(cr, uid, ids, context=context) #------------------------------------------------------ - # Generic message api + # mail.message wrappers and tools #------------------------------------------------------ def message_create(self, cr, uid, thread_id, vals, context=None): @@ -169,9 +169,9 @@ class mail_thread(osv.Model): # create message msg_id = message_obj.create(cr, uid, vals, context=context) - + # Set as unread if writer is not the document responsible - #model_pool.message_mark_as_unread(cr, uid, [res_id], context=context) + model_pool.message_create_check_state(cr, uid, [res_id], context=context) # special: if install mode, do not push demo data if context.get('install_mode', False): @@ -219,6 +219,10 @@ class mail_thread(osv.Model): user_ids = self.pool.get('res.users').search(cr, uid, [('login', 'in', login_lst)], context=context) return user_ids + #------------------------------------------------------ + # Generic message api + #------------------------------------------------------ + def message_capable_models(self, cr, uid, context=None): ret_dict = {} for model_name in self.pool.obj_list(): @@ -381,7 +385,6 @@ class mail_thread(osv.Model): original = msg_dict.get('original'), context = context) - # Message loading def _message_add_ancestor_ids(self, cr, uid, ids, child_ids, root_ids, context=None): """ Given message child_ids Find their ancestors until root ids""" @@ -425,6 +428,7 @@ class mail_thread(osv.Model): msg_ids = self.message_load_ids(cr, uid, ids, limit, offset, domain, ascent, root_ids, context=context) msgs = self.pool.get('mail.message').read(cr, uid, msg_ids, context=context) msgs = sorted(msgs, key=lambda d: (-d['id'])) + print 'tatayoyo' return msgs def get_pushed_messages(self, cr, uid, ids, limit=100, offset=0, msg_search_domain=[], ascent=False, root_ids=[], context=None): @@ -456,7 +460,7 @@ class mail_thread(osv.Model): return msgs #------------------------------------------------------ - # Email specific + # Mail gateway #------------------------------------------------------ # message_process will call either message_new or message_update. @@ -809,7 +813,8 @@ class mail_thread(osv.Model): # Trying to unsubscribe somebody not in subscribers: returns False # if special management is needed; allows to know that an automatically # subscribed user tries to unsubscribe and allows to warn him - if not user_ids and not uid in self.message_get_subscribers(cr, uid, ids, context=context): + mail_thread_model = self.pool.get('mail.thread') + if not user_ids and not uid in mail_thread_model.message_get_subscribers(cr, uid, ids, context=context): return False subscription_obj = self.pool.get('mail.subscription') to_unsubscribe_uids = [uid] if user_ids is None else user_ids @@ -835,13 +840,13 @@ class mail_thread(osv.Model): # Thread_state #------------------------------------------------------ - def message_mark_as_read(self, cr, uid, ids, context=None): - return self.write(cr, uid, ids, {'message_state': True}, context=context) - - def message_create_mark_as_unread(self, cr, uid, ids, context=None): + def message_create_check_state(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): if hasattr(obj, 'user_id') and (not obj.user_id or (obj.user_id and obj.user_id.id != uid)): - self.mark_as_unread(cr, uid, [obj.id], context=None) + self.mark_as_unread(cr, uid, [obj.id], context=context) + + def message_mark_as_read(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'message_state': True}, context=context) def message_mark_as_unread(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'message_state': False}, context=context) -- cgit v1.2.3 From c6eca7674d0577de00cc56f921ed5bbd7604c55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 21 Jun 2012 12:07:14 +0200 Subject: [FIX] mail_thread: fixed errors mechanism to set documents as unread. bzr revid: tde@openerp.com-20120621100714-3a1ygljteb3xd7g8 --- addons/mail/mail_thread.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index fb6d3e8f121..24b490cfbcd 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -171,7 +171,7 @@ class mail_thread(osv.Model): msg_id = message_obj.create(cr, uid, vals, context=context) # Set as unread if writer is not the document responsible - model_pool.message_create_check_state(cr, uid, [res_id], context=context) + self.message_create_check_state(cr, uid, [thread_id], context=context) # special: if install mode, do not push demo data if context.get('install_mode', False): @@ -843,7 +843,8 @@ class mail_thread(osv.Model): def message_create_check_state(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): if hasattr(obj, 'user_id') and (not obj.user_id or (obj.user_id and obj.user_id.id != uid)): - self.mark_as_unread(cr, uid, [obj.id], context=context) + print 'poinpoinponi' + self.message_mark_as_unread(cr, uid, [obj.id], context=context) def message_mark_as_read(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'message_state': True}, context=context) -- cgit v1.2.3 From 3dbce83bd7e99c90b50113ae056300ce76c059d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 21 Jun 2012 15:11:34 +0200 Subject: [ADD] mail_thread: added a message_summary field, holding the summary of Chatter. bzr revid: tde@openerp.com-20120621131134-kr02doztyedvc0eh --- addons/mail/mail_thread.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 24b490cfbcd..369058fff0e 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -62,19 +62,29 @@ class mail_thread(osv.Model): _name = 'mail.thread' _description = 'Email Thread' - def _get_message_ids(self, cr, uid, ids, name, arg, context=None): + def _get_message_ids(self, cr, uid, ids, name, args, context=None): res = {} for id in ids: - res[id] = self.message_load_ids(cr, uid, [id], context=context) + message_ids = self.message_load_ids(cr, uid, [id], context=context) + subscriber_ids = self.message_get_subscribers(cr, uid, [id], context=context) + res[id] = { + 'message_ids': message_ids, + 'message_summary': "(%d,%d)" % (len(message_ids), len(subscriber_ids)), + } + print res return res - + # OpenChatter: message_ids is a dummy field that should not be used _columns = { 'message_ids': fields.function(_get_message_ids, method=True, - type='one2many', obj='mail.message', string='Temp messages', _fields_id = 'res_id', - help="Functional field holding messages related to the current document."), + type='one2many', obj='mail.message', _fields_id = 'res_id', + string='Temp messages', multi="_get_message_ids", + help="Functional field holding messages related to the current document."), 'message_state': fields.boolean('Read', - help="When checked, new messages require your attention."), + help="When checked, new messages require your attention."), + 'message_summary': fields.function(_get_message_ids, method=True, + type='char', size=128, string='Summary', multi="_get_message_ids", + help="Holds the Chatter summary (number of messages, ...)."), } _defaults = { -- cgit v1.2.3 From 103aefe86391eb30f52dc31ce3d9692f24901809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 21 Jun 2012 15:12:48 +0200 Subject: [CLEAN] mail_thread: removed a 'print' statement. bzr revid: tde@openerp.com-20120621131248-dhatqbgcftn8vcp2 --- addons/mail/mail_thread.py | 1 - 1 file changed, 1 deletion(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 369058fff0e..fd4ef8ca056 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -71,7 +71,6 @@ class mail_thread(osv.Model): 'message_ids': message_ids, 'message_summary': "(%d,%d)" % (len(message_ids), len(subscriber_ids)), } - print res return res # OpenChatter: message_ids is a dummy field that should not be used -- cgit v1.2.3 From 13e23dba373658325402801bdc72099f857652bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 21 Jun 2012 17:23:11 +0200 Subject: [IMP] mail_thread: message_summary: now directly send html code. bzr revid: tde@openerp.com-20120621152311-fmqvxxaurvkuhl2b --- addons/mail/mail_thread.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index fd4ef8ca056..026d75b4be2 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -69,11 +69,10 @@ class mail_thread(osv.Model): subscriber_ids = self.message_get_subscribers(cr, uid, [id], context=context) res[id] = { 'message_ids': message_ids, - 'message_summary': "(%d,%d)" % (len(message_ids), len(subscriber_ids)), + 'message_summary': "Msg: %d . Fol: %d" % (len(message_ids), len(subscriber_ids)), } return res - - # OpenChatter: message_ids is a dummy field that should not be used + _columns = { 'message_ids': fields.function(_get_message_ids, method=True, type='one2many', obj='mail.message', _fields_id = 'res_id', @@ -82,8 +81,10 @@ class mail_thread(osv.Model): 'message_state': fields.boolean('Read', help="When checked, new messages require your attention."), 'message_summary': fields.function(_get_message_ids, method=True, - type='char', size=128, string='Summary', multi="_get_message_ids", - help="Holds the Chatter summary (number of messages, ...)."), + type='text', string='Summary', multi="_get_message_ids", + help="Holds the Chatter summary (number of messages, ...). "\ + "This summary is directly in html format in order to "\ + "be inserted in kanban views."), } _defaults = { -- cgit v1.2.3 From 133a31596207209683bc2a13e709b4b44409d0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 25 Jun 2012 18:13:12 +0200 Subject: [IMP] mark as (un)read implemented as a server action. bzr revid: tde@openerp.com-20120625161312-9m60ryduj77l46j9 --- addons/mail/mail_thread.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 88260b1e1e0..2ef9fc20d32 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -181,7 +181,7 @@ class mail_thread(osv.Model): msg_id = message_obj.create(cr, uid, vals, context=context) # Set as unread if writer is not the document responsible - self.message_create_check_state(cr, uid, [thread_id], context=context) + self.message_create_and_set_unread(cr, uid, [thread_id], context=context) # special: if install mode, do not push demo data if context.get('install_mode', False): @@ -438,6 +438,9 @@ class mail_thread(osv.Model): msg_ids = self.message_load_ids(cr, uid, ids, limit, offset, domain, ascent, root_ids, context=context) msgs = self.pool.get('mail.message').read(cr, uid, msg_ids, [], context=context) + # Set as read + self.message_check_and_set_read(cr, uid, ids, context=context) + """ Retrieve all attachments names """ map_id_to_name = {} @@ -461,7 +464,6 @@ class mail_thread(osv.Model): """ Sort and return messages """ msgs = sorted(msgs, key=lambda d: (-d['id'])) - print 'tatayoyo' return msgs def get_pushed_messages(self, cr, uid, ids, limit=100, offset=0, msg_search_domain=[], ascent=False, root_ids=[], context=None): @@ -873,17 +875,26 @@ class mail_thread(osv.Model): # Thread_state #------------------------------------------------------ - def message_create_check_state(self, cr, uid, ids, context=None): + def message_create_and_set_unread(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - if hasattr(obj, 'user_id') and (not obj.user_id or (obj.user_id and obj.user_id.id != uid)): - print 'poinpoinponi' + if obj.message_state and hasattr(obj, 'user_id') and (not obj.user_id or obj.user_id.id != uid): + self.message_mark_as_unread(cr, uid, [obj.id], context=context) + + def message_check_and_set_unread(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): + if obj.message_state and hasattr(obj, 'user_id') and (not obj.user_id or obj.user_id.id == uid): self.message_mark_as_unread(cr, uid, [obj.id], context=context) - def message_mark_as_read(self, cr, uid, ids, context=None): - return self.write(cr, uid, ids, {'message_state': True}, context=context) - def message_mark_as_unread(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'message_state': False}, context=context) + def message_check_and_set_read(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): + if not obj.message_state and hasattr(obj, 'user_id') and obj.user_id and obj.user_id.id == uid: + self.message_mark_as_read(cr, uid, [obj.id], context=context) + + def message_mark_as_read(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'message_state': True}, context=context) + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From 507b43cedf52efae1ac058e27d2e017a5e7762b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 29 Jun 2012 17:27:58 +0200 Subject: [IMP] mail.message: can now have void subjects. Void subjects are not displayed in chatter/wall; this allows to have a more flexible way to display blog post, while avoiding to display unnecessary data for notifications or quick replies. This imply that a way to manually add a subject when posting a comment is required; this will be done in openchatter part3. bzr revid: tde@openerp.com-20120629152758-9t23sdvtpdd49yyd --- addons/mail/mail_thread.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index e0f2bfaf455..d0af1ed8841 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -746,13 +746,8 @@ class mail_thread(osv.osv): self.message_append_note(cr, uid, [id], 'res.log', message, context=context) def message_append_note(self, cr, uid, ids, subject=None, body=None, parent_id=False, type='notification', subtype='html', context=None): - if subject is None: - if type == 'notification': - subject = _('System notification') - elif type == 'comment' and not parent_id: - subject = _('Comment') - elif type == 'comment' and parent_id: - subject = _('Reply') + if type in ['notification', 'reply']: + subject = None if subtype == 'html': body_html = body body_text = body -- cgit v1.2.3 From 8d9233f4ff0ae11a692cb244a0110ab3bdf4058d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 2 Jul 2012 17:46:30 +0200 Subject: [DOC] mail.thread: commented methods for message_state management. bzr revid: tde@openerp.com-20120702154630-jq8qunmfc5vhnl01 --- addons/mail/mail_thread.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 92dab65d44c..0e054281a7b 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -187,7 +187,7 @@ class mail_thread(osv.Model): msg_id = message_obj.create(cr, uid, vals, context=context) # Set as unread if writer is not the document responsible - self.message_create_and_set_unread(cr, uid, [thread_id], context=context) + self.message_create_set_unread(cr, uid, [thread_id], context=context) # special: if install mode, do not push demo data if context.get('install_mode', False): @@ -881,25 +881,32 @@ class mail_thread(osv.Model): # Thread_state #------------------------------------------------------ - def message_create_and_set_unread(self, cr, uid, ids, context=None): + def message_create_set_unread(self, cr, uid, ids, context=None): + """ When creating a new message, set as unread if uid is not the + object responsible. """ for obj in self.browse(cr, uid, ids, context=context): if obj.message_state and hasattr(obj, 'user_id') and (not obj.user_id or obj.user_id.id != uid): self.message_mark_as_unread(cr, uid, [obj.id], context=context) def message_check_and_set_unread(self, cr, uid, ids, context=None): + """ Set unread if uid is the object responsible or if the object has + no responsible. """ for obj in self.browse(cr, uid, ids, context=context): if obj.message_state and hasattr(obj, 'user_id') and (not obj.user_id or obj.user_id.id == uid): self.message_mark_as_unread(cr, uid, [obj.id], context=context) def message_mark_as_unread(self, cr, uid, ids, context=None): + """ Set as unread. """ return self.write(cr, uid, ids, {'message_state': False}, context=context) def message_check_and_set_read(self, cr, uid, ids, context=None): + """ Set read if uid is the object responsible. """ for obj in self.browse(cr, uid, ids, context=context): if not obj.message_state and hasattr(obj, 'user_id') and obj.user_id and obj.user_id.id == uid: self.message_mark_as_read(cr, uid, [obj.id], context=context) def message_mark_as_read(self, cr, uid, ids, context=None): + """ Set as read. """ return self.write(cr, uid, ids, {'message_state': True}, context=context) -- cgit v1.2.3 From 1ac5f6fa99fb15a1f58c1f7232ef9e0a803a63c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 2 Jul 2012 18:13:23 +0200 Subject: [REVIEW] Some cleaning after review and before merging. bzr revid: tde@openerp.com-20120702161323-wvd0j6ng3dz56ifj --- addons/mail/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index f69ccb39d7b..5668709af17 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -584,7 +584,7 @@ class mail_thread(osv.Model): # referenced thread was not found, we'll have to create a new one res_id = False if not res_id: - res_id = int(create_record(msg)) + res_id = create_record(msg) # To forward the email to other followers self.message_forward(cr, uid, model, [res_id], msg_txt, context=context) return res_id -- cgit v1.2.3