Vo Minh Thu (OpenERP) has proposed merging
lp:~openerp-dev/openobject-server/trunk-needaction-review-vmt into
lp:openobject-server.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-needaction-review-vmt/+merge/102064
--
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-needaction-review-vmt/+merge/102064
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/trunk-needaction-review-vmt.
=== renamed file 'doc/api/need_action_specs.rst' => 'doc/api/user_attention_specs.rst'
--- doc/api/need_action_specs.rst 2012-04-03 15:49:41 +0000
+++ doc/api/user_attention_specs.rst 2012-04-16 08:26:21 +0000
@@ -1,43 +1,43 @@
-Need action mechanism
-=====================
-
-ir.needaction mixin class
-++++++++++++++++++++++++++
-
-This revision adds a 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.
-
-This class wraps a class (ir.needaction_users) that behaves like a many2many field. However, no field is added to the model inheriting from base.needaction. The mixin class manages 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.
+"User attention" mechanism
+==========================
+
+ir.user_attention_mixin class
++++++++++++++++++++++++++++++
+
+This revision adds a mixin class for objects using the "user attention" feature.
+
+The "user action" feature can be used by objects willing to be able to signal that an action is required on a particular record, by a particular user. 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.user_record_attention_rel) that behaves like a many2many field. However, no field is added to the model inheriting from ir.user_attention_mixin. The mixin class manages the low-level considerations of updating relationships. Every change made on the record calls a method that updates the relationships.
+
+Objects using the "user attention" feature should override the ``get_attention_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,:
- - ``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)
- - ``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)
+ - ``get_attention_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)
+ - ``get_attention_record_count``: as ``get_attention_record_ids`` but returns only the number of action, not the ids (performs a search with count=True)
+ - ``get_attention_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)
Menu modification
+++++++++++++++++
This revision adds three functional fields to ``ir.ui.menu`` model :
- - ``uses_needaction``: boolean field. If the menu entry action is an act_window action, and if this action is related to a model that uses the need_action mechanism, this field is set to true. Otherwise, it is false.
- - ``needaction_uid_ctr``: integer field. If the target model uses the need action mechanism, this field gives the number of actions the current user has to perform.
- - ``needaction_record_ids``: many2many field. If the target model uses the need action mechanism, this field holds the ids of the record requesting the user to perform an action.
+ - ``user_attention_enabled``: boolean field. If the menu entry action is an act_window action, and if this action is related to a model that uses the "user attention" mechanism, this field is set to true. Otherwise, it is false.
+ - ``user_attention_counter``: integer field. If the target model uses the "user attention" mechanism, this field gives the number of actions the current user has to perform.
+ - ``user_attention_record_ids``: many2many field. If the target model uses the "user attention" mechanism, this field holds the ids of the record requesting the user to perform an action.
-Those fields are functional, because they depend on the user and must therefore be computed at every refresh, each time menus are displayed. The use of the need action mechanism is done by taking into account the action domain in order to display accurate results. When computing the value of the functional fields, the ids of records asking the user to perform an action is concatenated to the action domain. A counting search is then performed on the model, giving back the number of action the users has to perform, limited to the domain of the action.
+Those fields are functional, because they depend on the user and must therefore be computed at every refresh, each time menus are displayed. The use of the "user attention" mechanism is done by taking into account the action domain in order to display accurate results. When computing the value of the functional fields, the ids of records asking the user to perform an action is concatenated to the action domain. A counting search is then performed on the model, giving back the number of action the users has to perform, limited to the domain of the action.
Addon implementation example
++++++++++++++++++++++++++++
-In your ``foo`` module, you want to specify that when it is in state ``confirmed``, it has to be validated by a manager, given by the field ``manager_id``. After making ``foo`` inheriting from ``base.needaction``, you override the ``get_needaction_user_ids`` method:
+In your ``foo`` module, you want to specify that when it is in state ``confirmed``, it has to be validated by a manager, given by the field ``manager_id``. After making ``foo`` inheriting from ``ir_user_attention_mixin``, you override the ``get_attention_user_ids`` method:
::
[...]
- _inherit = [base.needaction]
+ _inherit = [ir.user_attention_mixin]
[...]
- def get_needaction_user_ids(self, cr, uid, ids, context=None):
+ def get_attention_user_ids(self, cr, uid, ids, context=None):
result = dict.fromkeys(ids)
for foo_obj in self.browse(cr, uid, ids, context=context):
# set the list void by default
=== modified file 'doc/index.rst.inc'
--- doc/index.rst.inc 2012-03-30 12:03:59 +0000
+++ doc/index.rst.inc 2012-04-16 08:26:21 +0000
@@ -14,4 +14,4 @@
:maxdepth: 1
api/user_img_specs
- api/need_action_specs
+ api/user_attention_specs
=== modified file 'openerp/addons/base/ir/__init__.py'
--- openerp/addons/base/ir/__init__.py 2012-03-30 13:24:52 +0000
+++ openerp/addons/base/ir/__init__.py 2012-04-16 08:26:21 +0000
@@ -21,7 +21,7 @@
import ir_model
import ir_sequence
-import ir_needaction
+import ir_user_attention
import ir_ui_menu
import ir_ui_view
import ir_default
=== modified file 'openerp/addons/base/ir/ir.xml'
--- openerp/addons/base/ir/ir.xml 2012-04-06 08:19:37 +0000
+++ openerp/addons/base/ir/ir.xml 2012-04-16 08:26:21 +0000
@@ -661,10 +661,10 @@
<menuitem action="ir_action_wizard" id="menu_ir_action_wizard" parent="base.next_id_6"/>
- <!-- Needaction mechanism -->
- <record model="ir.ui.view" id="view_ir_needaction_users_tree">
- <field name="name">ir.needaction_users.tree</field>
- <field name="model">ir.needaction_users</field>
+ <!-- "user attention" mechanism -->
+ <record model="ir.ui.view" id="view_ir_user_attention_tree">
+ <field name="name">ir.user_attention.tree</field>
+ <field name="model">ir.user_record_attention_rel</field>
<field name="type">tree</field>
<field name="sequence">10</field>
<field name="arch" type="xml">
@@ -676,14 +676,14 @@
</field>
</record>
- <record id="action_view_needaction_users" model="ir.actions.act_window">
- <field name="name">Need action relationships</field>
- <field name="res_model">ir.needaction_users</field>
+ <record id="action_view_user_attention" model="ir.actions.act_window">
+ <field name="name">"User attention" relationship</field>
+ <field name="res_model">ir.user_record_attention_rel</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
- <menuitem id="menu_needaction_users" name="Need actions" parent="base.menu_users" sequence="20" action="action_view_needaction_users" groups="base.group_no_one"/>
+ <menuitem id="menu_user_attention" name="User attention" parent="base.menu_users" sequence="20" action="action_view_user_attention" groups="base.group_no_one"/>
<!-- Companies -->
<menuitem id="menu_res_company_global"
=== modified file 'openerp/addons/base/ir/ir_ui_menu.py'
--- openerp/addons/base/ir/ir_ui_menu.py 2012-04-06 08:17:26 +0000
+++ openerp/addons/base/ir/ir_ui_menu.py 2012-04-16 08:26:21 +0000
@@ -255,22 +255,22 @@
return res
- def _get_needaction(self, cr, uid, ids, field_names, args, context=None):
+ def _get_user_attention(self, cr, uid, ids, field_names, args, context=None):
if context is None:
context = {}
- res = dict.fromkeys(ids)
+ res = {}
for menu in self.browse(cr, uid, ids, context=context):
res[menu.id] = {}
if menu.action and menu.action.type == 'ir.actions.act_window' and menu.action.res_model:
- menu_needaction_res = self.pool.get(menu.action.res_model).get_needaction_info(cr, uid, uid, domain=menu.action.domain, context=context)
+ menu_user_attention_res = self.pool.get(menu.action.res_model)._get_attention_user_info(cr, uid, uid, domain=menu.action.domain, context=context)
# TODO: find the addon that causes a bug on runbot, not on local
- if not isinstance(menu_needaction_res[1], (int, long)): menu_needaction_res[1] = 0
+ if not isinstance(menu_user_attention_res[1], (int, long)): menu_user_attention_res[1] = 0
else:
- menu_needaction_res = [False, 0, ()]
- res[menu.id]['needaction_enabled'] = menu_needaction_res[0]
- res[menu.id]['needaction_counter'] = menu_needaction_res[1]
+ menu_user_attention_res = [False, 0, ()]
+ res[menu.id]['user_attention_enabled'] = menu_user_attention_res[0]
+ res[menu.id]['user_attention_counter'] = menu_user_attention_res[1]
# not used currently, therefore set to a void list
- res[menu.id]['needaction_record_ids'] = []
+ res[menu.id]['user_attention_record_ids'] = menu_user_attention_res[2]
return res
_columns = {
@@ -289,9 +289,9 @@
'web_icon_hover':fields.char('Web Icon File (hover)', size=128),
'web_icon_data': fields.function(_get_image_icon, string='Web Icon Image', type='binary', readonly=True, store=True, multi='icon'),
'web_icon_hover_data':fields.function(_get_image_icon, string='Web Icon Image (hover)', type='binary', readonly=True, store=True, multi='icon'),
- 'needaction_enabled': fields.function(_get_needaction, string='Target model uses the need action mechanism', type='boolean', help='If the menu entry action is an act_window action, and if this action is related to a model that uses the need_action mechanism, this field is set to true. Otherwise, it is false.', multi='_get_needaction'),
- 'needaction_counter': fields.function(_get_needaction, string='Number of actions the user has to perform', type='integer', help='If the target model uses the need action mechanism, this field gives the number of actions the current user has to perform.', multi='_get_needaction'),
- 'needaction_record_ids': fields.function(_get_needaction, string='Ids of records requesting an action from the user', type='many2many', help='If the target model uses the need action mechanism, this field holds the ids of the record requesting the user to perform an action.', multi='_get_needaction'),
+ 'user_attention_enabled': fields.function(_get_user_attention, string='Target model uses the "user attention" mechanism', type='boolean', help='If the menu entry action is an act_window action, and if this action is related to a model that uses the "user attention" mechanism, this field is set to true. Otherwise, it is false.', multi='_get_user_attention'),
+ 'user_attention_counter': fields.function(_get_user_attention, string='Number of actions the user has to perform', type='integer', help='If the target model uses the "user attention" mechanism, this field gives the number of actions the current user has to perform.', multi='_get_user_attention'),
+ 'user_attention_record_ids': fields.function(_get_user_attention, string='Ids of records requesting an action from the user', type='many2many', help='If the target model uses the "user attention" mechanism, this field holds the ids of the record requesting the user to perform an action.', multi='_get_user_attention'),
'action': fields.function(_action, fnct_inv=_action_inv,
type='reference', string='Action',
selection=[
=== renamed file 'openerp/addons/base/ir/ir_needaction.py' => 'openerp/addons/base/ir/ir_user_attention.py'
--- openerp/addons/base/ir/ir_needaction.py 2012-04-03 16:41:27 +0000
+++ openerp/addons/base/ir/ir_user_attention.py 2012-04-16 08:26:21 +0000
@@ -24,18 +24,20 @@
from osv import osv, fields
from tools.translate import _
-class ir_needaction_users(osv.osv):
+class ir_user_record_attention_rel(osv.osv):
'''
- ir_needaction_users holds data related to the needaction
- mechanism inside OpenERP. A needaction is characterized by:
+ ir_user_record_attention_rel holds data related to the 'user attention'
+ 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).
'''
- _name = 'ir.needaction_users'
- _description = 'Needaction relationship table'
+ _name = 'ir.user_record_attention_rel'
+ _description = '"user attention" relationship table'
_rec_name = 'id'
_order = 'id desc'
_columns = {
@@ -49,15 +51,11 @@
def _get_users(self, cr, uid, res_ids, res_model, context=None):
"""Given res_ids of res_model, get user_ids present in table"""
- if context is None:
- context = {}
- needact_ids = self.search(cr, uid, [('res_model', '=', res_model), ('res_id', 'in', res_ids)], context=context)
- return map(itemgetter('res_id'), self.read(cr, uid, needact_ids, context=context))
+ rel_ids = self.search(cr, uid, [('res_model', '=', res_model), ('res_id', 'in', res_ids)], context=context)
+ return list(set(map(itemgetter('user_id'), self.read(cr, uid, rel_ids, ['user_id'], context=context))))
def create_users(self, cr, uid, res_ids, res_model, user_ids, context=None):
"""Given res_ids of res_model, add user_ids to the relationship table"""
- if context is None:
- context = {}
for res_id in res_ids:
for user_id in user_ids:
self.create(cr, uid, {'res_model': res_model, 'res_id': res_id, 'user_id': user_id}, context=context)
@@ -65,8 +63,6 @@
def unlink_users(self, cr, uid, res_ids, res_model, context=None):
"""Given res_ids of res_model, delete all entries in the relationship table"""
- if context is None:
- context = {}
to_del_ids = self.search(cr, uid, [('res_model', '=', res_model), ('res_id', 'in', res_ids)], context=context)
return self.unlink(cr, uid, to_del_ids, context=context)
@@ -74,7 +70,7 @@
"""Given res_ids of res_model, update their entries in the relationship table to user_ids"""
# read current records
cur_users = self._get_users(cr, uid, res_ids, res_model, context=context)
- if len(cur_users) == len(user_ids) and all([cur_user in user_ids for cur_user in cur_users]):
+ if len(cur_users) == len(user_ids) and all(cur_user in user_ids for cur_user in cur_users):
return True
# unlink old records
self.unlink_users(cr, uid, res_ids, res_model, context=context)
@@ -83,116 +79,103 @@
return True
-class ir_needaction_mixin(osv.osv):
- '''Mixin class for objects using the need action feature.
+class ir_user_attention_mixin(osv.osv):
+ '''Mixin class for objects using the 'user attention' feature.
- Need action feature can be used by objects willing to be able to
+ The "user attention" 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.
- This class wraps a class (ir.needaction_users) that behaves
+ This class wraps a class (ir.user_record_attention_rel) that behaves
like a many2many field. However, no field is added to the model
- inheriting from base.needaction. The mixin class manages the low-level
- considerations of updating relationships. Every change made on the
- record calls a method that updates the relationships.
+ inheriting from this mixin class. This mixin class manages the low-level
+ considerations of updating the relationship. Every change made on the
+ record calls a method that updates the relationship.
- Objects using the need_action feature should override the
- ``get_needaction_user_ids`` method. This methods returns a dictionary
+ Objects using the 'user attention' feature should override the
+ ``get_attention_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,:
- - ``needaction_get_record_ids``: for the current model and uid, get
+ - ``get_attention_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)
- - ``needaction_get_action_count``: as ``needaction_get_record_ids``
+ - ``get_attention_record_count``: as ``get_attention_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
+ - ``get_attention_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)
'''
- _name = 'ir.needaction_mixin'
- _description = 'Need action of users on records API'
+ _name = 'ir.user_attention_mixin'
+ _description = '"user attention" mixin'
#------------------------------------------------------
# Addon API
#------------------------------------------------------
- def get_needaction_user_ids(self, cr, uid, ids, context=None):
+ def get_attention_user_ids(self, cr, uid, ids, context=None):
""" Returns the user_ids that have to perform an action
:return: dict { record_id: [user_ids], }
"""
return dict.fromkeys(ids, [])
def create(self, cr, uid, values, context=None):
- if context is None:
- context = {}
- needact_table_obj = self.pool.get('ir.needaction_users')
+ rel_obj = self.pool.get('ir.user_record_attention_rel')
# perform create
- obj_id = super(ir_needaction_mixin, self).create(cr, uid, values, context=context)
+ obj_id = super(ir_user_attention_mixin, self).create(cr, uid, values, context=context)
# link user_ids
- needaction_user_ids = self.get_needaction_user_ids(cr, uid, [obj_id], context=context)
- needact_table_obj.create_users(cr, uid, [obj_id], self._name, needaction_user_ids[obj_id], context=context)
+ attention_user_ids = self.get_attention_user_ids(cr, uid, [obj_id], context=context)
+ rel_obj.create_users(cr, uid, [obj_id], self._name, attention_user_ids[obj_id], context=context)
return obj_id
def write(self, cr, uid, ids, values, context=None):
- if context is None:
- context = {}
- needact_table_obj = self.pool.get('ir.needaction_users')
+ rel_obj = self.pool.get('ir.user_record_attention_rel')
# perform write
- write_res = super(ir_needaction_mixin, self).write(cr, uid, ids, values, context=context)
+ write_res = super(ir_user_attention_mixin, self).write(cr, uid, ids, values, context=context)
# get and update user_ids
- needaction_user_ids = self.get_needaction_user_ids(cr, uid, ids, context=context)
+ attention_user_ids = self.get_attention_user_ids(cr, uid, ids, context=context)
for id in ids:
- needact_table_obj.update_users(cr, uid, [id], self._name, needaction_user_ids[id], context=context)
+ rel_obj.update_users(cr, uid, [id], self._name, attention_user_ids[id], context=context)
return write_res
def unlink(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
# unlink user_ids
- needact_table_obj = self.pool.get('ir.needaction_users')
- needact_table_obj.unlink_users(cr, uid, ids, self._name, context=context)
+ rel_obj = self.pool.get('ir.user_record_attention_rel')
+ rel_obj.unlink_users(cr, uid, ids, self._name, context=context)
# perform unlink
- return super(ir_needaction_mixin, self).unlink(cr, uid, ids, context=context)
-
- #------------------------------------------------------
- # Need action API
- #------------------------------------------------------
-
- def needaction_get_record_ids(self, cr, uid, user_id, limit=80, context=None):
- """Given the current model and a user_id
- get the number of actions it has to perform"""
- if context is None:
- context = {}
- needact_table_obj = self.pool.get('ir.needaction_users')
- needact_table_ids = needact_table_obj.search(cr, uid, [('res_model', '=', self._name), ('user_id', '=', user_id)], limit=limit, context=context)
- return map(itemgetter('res_id'), needact_table_obj.read(cr, uid, needact_table_ids, context=context))
-
- def needaction_get_action_count(self, cr, uid, user_id, limit=80, context=None):
- """Given the current model and a user_id
- get the number of actions it has to perform"""
- if context is None:
- context = {}
- needact_table_obj = self.pool.get('ir.needaction_users')
- return needact_table_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):
+ return super(ir_user_attention_mixin, self).unlink(cr, uid, ids, context=context)
+
+ #------------------------------------------------------
+ # "user attention" API
+ #------------------------------------------------------
+
+ def get_attention_record_ids(self, cr, uid, user_id, limit=80, context=None):
+ """Given the current model and a user_id
+ return the records ids that need the user attention"""
+ rel_obj = self.pool.get('ir.user_record_attention_rel')
+ rel_ids = rel_obj.search(cr, uid, [('res_model', '=', self._name), ('user_id', '=', user_id)], limit=limit, context=context)
+ return map(itemgetter('res_id'), rel_obj.read(cr, uid, rel_ids, ['res_id'], context=context))
+
+ def get_attention_record_count(self, cr, uid, user_id, limit=80, context=None):
+ """Given the current model and a user_id
+ get the number of actions it has to perform"""
+ rel_obj = self.pool.get('ir.user_record_attention_rel')
+ return rel_obj.search(cr, uid, [('res_model', '=', self._name), ('user_id', '=', user_id)], limit=limit, count=True, context=context)
+
+ def get_attention_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."""
- if context is None:
- context = {}
- needact_table_obj = self.pool.get('ir.needaction_users')
- needact_table_ids = needact_table_obj.search(cr, uid, [('user_id', '=', user_id)], offset=offset, limit=limit, order=order, context=context)
- needact_records = needact_table_obj.read(cr, uid, needact_table_ids, context=context)
- return map(itemgetter('res_model', 'id'), needact_records)
+ rel_obj = self.pool.get('ir.user_record_attention_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:
=== modified file 'openerp/addons/base/security/ir.model.access.csv'
--- openerp/addons/base/security/ir.model.access.csv 2012-04-04 13:33:28 +0000
+++ openerp/addons/base/security/ir.model.access.csv 2012-04-16 08:26:21 +0000
@@ -121,6 +121,6 @@
"access_ir_mail_server_all","ir_mail_server","model_ir_mail_server",,1,0,0,0
"access_ir_actions_todo_category","ir_actions_todo_category","model_ir_actions_todo_category","group_system",1,1,1,1
"access_ir_actions_client","ir_actions_client all","model_ir_actions_client",,1,0,0,0
-"access_ir_needaction_users","ir_needaction_users","model_ir_needaction_users",,1,1,1,1
-"access_ir_needaction_mixin","ir_needaction_mixin","model_ir_needaction_mixin",,1,1,1,1
+"access_ir_user_record_attention_rel","ir_user_record_attention_rel","model_ir_user_record_attention_rel",,1,1,1,1
+"access_ir_user_attention_mixin","ir_user_attention_mixin","model_ir_user_attention_mixin",,1,1,1,1
=== modified file 'openerp/osv/orm.py'
--- openerp/osv/orm.py 2012-04-05 16:52:00 +0000
+++ openerp/osv/orm.py 2012-04-16 08:26:21 +0000
@@ -4866,11 +4866,11 @@
get_xml_id = get_external_id
_get_xml_ids = _get_external_ids
- def get_needaction_info(self, cr, uid, user_id, limit=None, order=None, domain=False, context=None):
- """Base method for needaction mechanism
- - see ir.needaction for actual implementation
- - if the model uses the need action mechanism
- (hasattr(model_obj, 'needaction_get_record_ids')):
+ def _get_attention_user_info(self, cr, uid, user_id, limit=None, order=None, domain=False, context=None):
+ """Base method for 'user attention' mechanism
+ - see ir.user_attention_mixin for actual implementation
+ - if the model uses the 'user attention' mechanism
+ (hasattr(model_obj, 'get_attention_record_ids')):
- get the record ids on which the user has actions to perform
- evaluate the menu domain
- compose a new domain: menu domain, limited to ids of
@@ -4880,10 +4880,12 @@
- this method returns default values
:param: model_name: the name of the model (ex: hr.holidays)
:param: user_id: the id of user
- :return: [uses_needaction=True/False, needaction_uid_ctr=%d]
+ :return: [uses_user_attention=True/False, attention_record_count=%d, res_ids]
"""
- if hasattr(self, 'needaction_get_record_ids'):
- ids = self.needaction_get_record_ids(cr, uid, user_id, limit=8192, context=context)
+ if hasattr(self, 'get_attention_record_ids'):
+ # Arbitrary limit, but still much lower thant infinity, to avoid
+ # getting too much data.
+ ids = self.get_attention_record_ids(cr, uid, user_id, limit=8192, context=context)
if not ids:
return [True, 0, []]
if domain:
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp