diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index f0dd023bf06..a79b5a6475a 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -189,7 +189,7 @@ class mail_thread(osv.Model): notif_user_ids += self.message_parse_users(cr, uid, body, context=context) # add users requested to perform an action (need_action mechanism) - if hasattr(self, 'get_needaction_user_ids'): + if self._columns.get('user_id'): user_ids_dict = self.get_needaction_user_ids(cr, uid, thread_ids, context=context) for id, user_ids in user_ids_dict.iteritems(): notif_user_ids += user_ids @@ -805,7 +805,7 @@ class mail_thread(osv.Model): forward_to = [i for i in message_followers_emails if (i and (i not in message_recipients))] if forward_to: # TODO: we need an interface for this for all types of objects, not just leads - if hasattr(res, 'section_id'): + if model_pool._columns.get('section_id'): del msg['reply-to'] msg['reply-to'] = res.section_id.reply_to @@ -1047,14 +1047,14 @@ class mail_thread(osv.Model): """ 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): + if obj.message_state and self._columns.get('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): + if obj.message_state and self._columns.get('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): @@ -1064,7 +1064,7 @@ class mail_thread(osv.Model): 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: + if not obj.message_state and self._columns.get('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):