[ADD] Added a 'needaction_pending' field: this states whether the record has an actio...
authorThibault Delavallée <tde@openerp.com>
Wed, 18 Apr 2012 09:41:01 +0000 (11:41 +0200)
committerThibault Delavallée <tde@openerp.com>
Wed, 18 Apr 2012 09:41:01 +0000 (11:41 +0200)
bzr revid: tde@openerp.com-20120418094101-o0a9lcpux8b6d75u

openerp/addons/base/ir/ir_needaction.py

index 6dd9cdf..7270eb2 100644 (file)
@@ -115,6 +115,21 @@ class ir_needaction_mixin(osv.osv):
     _name = 'ir.needaction_mixin'
     _description = '"Need action" mixin'
     
+    def get_needaction_pending(self, cr, uid, ids, name, arg, context=None):
+        res = {}
+        rel_obj = self.pool.get('ir.needaction_users_rel')
+        for id in ids:
+            res[id] = rel_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', '=', id), ('user_id', '=', uid)], limit=1, count=True, context=context) > 0
+        return res
+    
+    _columns = {
+        'needaction_pending': fields.function(get_needaction_pending, type='boolean',
+                        string='Need action pending',
+                        help='If True, this field states that users have to perform an action. \
+                                This field comes from the needaction mechanism. Please refer \
+                                to the ir.needaction_mixin class.'),
+    }
+    
     #------------------------------------------------------
     # Addon API
     #------------------------------------------------------