diff --git a/openerp/addons/base/base_menu.xml b/openerp/addons/base/base_menu.xml
index abba27b7ed7..90c7dd348e6 100644
--- a/openerp/addons/base/base_menu.xml
+++ b/openerp/addons/base/base_menu.xml
@@ -1,23 +1,22 @@
-
+
-
+
-
+
-
-
-
+
+
+
+
-
-
diff --git a/openerp/addons/base/ir/ir.xml b/openerp/addons/base/ir/ir.xml
index 392bb60c53e..88843b207f9 100644
--- a/openerp/addons/base/ir/ir.xml
+++ b/openerp/addons/base/ir/ir.xml
@@ -328,7 +328,7 @@
-
+
diff --git a/openerp/addons/base/ir/ir_config_parameter_view.xml b/openerp/addons/base/ir/ir_config_parameter_view.xml
index 3df9b80551c..6b1c6c4f86e 100644
--- a/openerp/addons/base/ir/ir_config_parameter_view.xml
+++ b/openerp/addons/base/ir/ir_config_parameter_view.xml
@@ -40,7 +40,6 @@
-
+
diff --git a/openerp/addons/base/ir/ir_needaction.py b/openerp/addons/base/ir/ir_needaction.py
index 75a6c6cb523..0f28c33ded9 100644
--- a/openerp/addons/base/ir/ir_needaction.py
+++ b/openerp/addons/base/ir/ir_needaction.py
@@ -24,16 +24,16 @@ from operator import itemgetter
from osv import osv, fields
from tools.translate import _
-class ir_needaction_users_rel(osv.osv):
- '''
- ir_needaction_users_rel holds data related to the needaction
- mechanism inside OpenERP. A row in this model is characterized by:
+class ir_needaction_users_rel(osv.Model):
+ ''' ir_needaction_users_rel holds data related to the needaction
+ mechanism inside OpenERP. A row in this model is characterized
+ by:
- res_model: model of the record requiring an action
- res_id: ID of the record requiring an action
- - user_id: foreign key to the res.users table, to the user that
- has to perform the action
- This model can be seen as a many2many, linking (res_model, res_id) to
- users (those whose attention is required on the record).'''
+ - user_id: foreign key to the res.users table, to the user that has to
+ perform the action
+ This model can be seen as a many2many, linking (res_model, res_id) to users
+ (those whose attention is required on the record). '''
_name = 'ir.needaction_users_rel'
_description = 'Needaction relationship table'
@@ -78,50 +78,47 @@ class ir_needaction_users_rel(osv.osv):
return True
-class ir_needaction_mixin(osv.osv):
+class ir_needaction_mixin(osv.Model):
'''Mixin class for objects using the need action feature.
- Need action feature can be used by objects willing to be able to
- signal that an action is required on a particular record. If in the
- business logic an action must be performed by somebody, for instance
- validation by a manager, this mechanism allows to set a list of
- users asked to perform an action.
+ Need action feature can be used by objects having to be able to
+ signal that an action is required on a particular record. If in
+ the business logic an action must be performed by somebody, for
+ instance validation by a manager, this mechanism allows to set a
+ list of users asked to perform an action.
- This class wraps a class (ir.ir_needaction_users_rel) that behaves
- like a many2many field. However, no field is added to the model
- inheriting from this mixin class. This class handles the low-level
- considerations of updating relationships. Every change made on the
- record calls a method that updates the relationships.
+ This class wraps a class (ir.ir_needaction_users_rel) that
+ behaves like a many2many field. This class handles the low-level
+ considerations of updating relationships. Every change made on
+ the record calls a method that updates the relationships.
- Objects using the 'need_action' feature should override the
- ``get_needaction_user_ids`` method. This methods returns a dictionary
- whose keys are record ids, and values a list of user ids, like
- in a many2many relationship. Therefore by defining only one method,
- you can specify if an action is required by defining the users
- that have to do it, in every possible situation.
+ Objects using the 'need_action' feature should override the
+ ``get_needaction_user_ids`` method. This methods returns a
+ dictionary whose keys are record ids, and values a list of user
+ ids, like in a many2many relationship. Therefore by defining
+ only one method, you can specify if an action is required by
+ defining the users that have to do it, in every possible
+ situation.
- This class also offers several global services,:
+ This class also offers several global services:
- ``needaction_get_record_ids``: for the current model and uid, get
- all record ids that ask this user to perform an action. This
- mechanism is used for instance to display the number of pending
- actions in menus, such as Leads (12)
+ all record ids that ask this user to perform an action. This
+ mechanism is used for instance to display the number of pending
+ actions in menus, such as Leads (12)
- ``needaction_get_action_count``: as ``needaction_get_record_ids``
- but returns only the number of action, not the ids (performs a
- search with count=True)
- - ``needaction_get_user_record_references``: for a given uid, get all
- the records that ask this user to perform an action. Records
- are given as references, a list of tuples (model_name, record_id)
+ but returns only the number of action, not the ids (performs a
+ search with count=True)
- The ``ir_needaction_mixin`` class adds a function field on models inheriting
- from the class. This field allows to state whether a given record has
- a needaction for the current user. This is usefull if you want to customize
- views according to the needaction feature. For example, you may want to
- set records in bold in a list view if the current user has an action to
- perform on the record. This makes the class not a pure abstract class,
- but allows to easily use the action information.'''
+ The ``ir_needaction_mixin`` class adds a calculated field
+ ``needaction_pending``. This function field allows to state
+ whether a given record has a needaction for the current user.
+ This is usefull if you want to customize views according to the
+ needaction feature. For example, you may want to set records in
+ bold in a list view if the current user has an action to perform
+ on the record. '''
_name = 'ir.needaction_mixin'
- _description = '"Need action" mixin'
+ _description = 'Need action mixin'
def get_needaction_pending(self, cr, uid, ids, name, arg, context=None):
res = {}
@@ -129,13 +126,19 @@ class ir_needaction_mixin(osv.osv):
for id in ids:
res[id] = uid in needaction_user_ids[id]
return res
+
+ def search_needaction_pending(self, cr, uid, self_again, field_name, criterion, context=None):
+ ids = self.needaction_get_record_ids(
+ cr, uid, uid, limit=1024, context=context)
+ return [('id', 'in', ids)]
_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.'),
+ 'needaction_pending': fields.function(
+ get_needaction_pending, type='boolean',
+ fnct_search=search_needaction_pending,
+ string='Need action pending',
+ help="If True, this field states that users have to perform an " \
+ "action This field comes from the ir.needaction_mixin class."),
}
#------------------------------------------------------
@@ -146,7 +149,7 @@ class ir_needaction_mixin(osv.osv):
""" Returns the user_ids that have to perform an action
:return: dict { record_id: [user_ids], }
"""
- return dict.fromkeys(ids, [])
+ return dict((id,list()) for id in ids)
def create(self, cr, uid, values, context=None):
rel_obj = self.pool.get('ir.needaction_users_rel')
@@ -191,14 +194,5 @@ class ir_needaction_mixin(osv.osv):
get the number of actions it has to perform"""
rel_obj = self.pool.get('ir.needaction_users_rel')
return rel_obj.search(cr, uid, [('res_model', '=', self._name), ('user_id', '=', user_id)], limit=limit, count=True, context=context)
-
- def needaction_get_record_references(self, cr, uid, user_id, offset=None, limit=None, order=None, context=None):
- """For a given user_id, get all the records that asks this user to
- perform an action. Records are given as references, a list of
- tuples (model_name, record_id).
- This method is trans-model."""
- rel_obj = self.pool.get('ir.needaction_users_rel')
- rel_ids = rel_obj.search(cr, uid, [('user_id', '=', user_id)], offset=offset, limit=limit, order=order, context=context)
- return map(itemgetter('res_model', 'res_id'), rel_obj.read(cr, uid, rel_ids, ['res_model', 'res_id'], context=context))
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/openerp/addons/base/ir/workflow/workflow_view.xml b/openerp/addons/base/ir/workflow/workflow_view.xml
index bda98b7c8c0..89809d327ae 100644
--- a/openerp/addons/base/ir/workflow/workflow_view.xml
+++ b/openerp/addons/base/ir/workflow/workflow_view.xml
@@ -317,7 +317,7 @@
{'search_default_active':1}
-
+