[IMP] mail_thread: replaced hasattr by check in columns.
authorThibault Delavallée <tde@openerp.com>
Mon, 13 Aug 2012 09:06:41 +0000 (11:06 +0200)
committerThibault Delavallée <tde@openerp.com>
Mon, 13 Aug 2012 09:06:41 +0000 (11:06 +0200)
bzr revid: tde@openerp.com-20120813090641-n8o08be2ecfxxtdz

addons/mail/mail_thread.py

index f0dd023..a79b5a6 100644 (file)
@@ -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):