Thibault Delavallée (OpenERP) has proposed merging
lp:~openerp-dev/openobject-server/trunk-need_action-tde into
lp:openobject-server.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-need_action-tde/+merge/97207
Need action mixin class
=======================
This revision adds a mixin class for object implementing the need action
mechanism. Need action mechanism can be used by objects that have 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 field with the user_id of the user
requested to perform the action.
Technically, this class adds a need_action_user_id field; when set to false, no
action is required; when an user_id is set, this user has an action to perform.
This field is a function field. Setting an user_id is done through redefining
the get_needaction_user_id method. Therefore by redefining only one method, you
can specify the cases in which an action will be required on a particular
record.
This mechanism is used for instance to display the number of pending actions in
menus, such as Leads (12).
--
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-need_action-tde/+merge/97207
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/trunk-need_action-tde.
=== added file 'doc/api/need_action_specs.rst'
--- doc/api/need_action_specs.rst 1970-01-01 00:00:00 +0000
+++ doc/api/need_action_specs.rst 2012-03-13 12:34:18 +0000
@@ -0,0 +1,8 @@
+Need action mixin class
+=======================
+
+This revision adds a mixin class for object implementing the need action mechanism. Need action mechanism can be used by objects that have 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 field with the user_id of the user requested to perform the action.
+
+Technically, this class adds a need_action_user_id field; when set to false, no action is required; when an user_id is set, this user has an action to perform. This field is a function field. Setting an user_id is done through redefining the get_needaction_user_id method. Therefore by redefining only one method, you can specify the cases in which an action will be required on a particular record.
+
+This mechanism is used for instance to display the number of pending actions in menus, such as Leads (12).
=== modified file 'doc/index.rst.inc'
--- doc/index.rst.inc 2012-03-05 14:07:38 +0000
+++ doc/index.rst.inc 2012-03-13 12:34:18 +0000
@@ -6,3 +6,11 @@
:maxdepth: 1
test-framework
+
+New feature merges
+++++++++++++++++++
+
+.. toctree::
+ :maxdepth: 1
+
+ api/need_action_specs
=== added file 'openerp/addons/base/base_needaction.py'
--- openerp/addons/base/base_needaction.py 1970-01-01 00:00:00 +0000
+++ openerp/addons/base/base_needaction.py 2012-03-13 12:34:18 +0000
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2009-Today OpenERP SA (<http://www.openerp.com>)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+#
+##############################################################################
+
+from osv import osv, fields
+from tools.translate import _
+
+class base_needaction(osv.osv):
+ '''Mixin class for object implementing the need action mechanism.
+
+ Need action mechanism can be used by objects that have 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 field with
+ the user_id of the user requested to perform the action.
+
+ Technically, this class adds a need_action_user_id field; when
+ set to false, no action is required; when an user_id is set,
+ this user has an action to perform. This field is a function field.
+ Setting an user_id is done through redefining the get_needaction_user_id method.
+ Therefore by redefining only one method, you can specify
+ the cases in which an action will be required on a particular record.
+
+ This mechanism is used for instance to display the number of pending actions
+ in menus, such as Leads (12).
+ '''
+ _name = 'base.needaction'
+ _description = 'Need action mechanism'
+
+ def get_needaction_user_id(self, cr, uid, ids, name, arg, context=None):
+ if context is None:
+ context = {}
+ result = {}
+ for id in ids:
+ result[id] = False
+ return result
+
+ ''' Wrapper: in 6.1 the reference to a method is given to a function
+ field, not the function name. Inheritance is therefore not directly
+ possible.'''
+ def get_needaction_user_id_wrapper(self, cr, uid, ids, name, arg, context=None):
+ return self.get_needaction_user_id(cr, uid, ids, name, arg, context=context)
+
+ _columns = {
+ 'need_action_user_id': fields.function(get_needaction_user_id_wrapper,
+ type='many2one', relation='res.users', store=True,
+ select=1, string='User'),
+ }
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
_______________________________________________
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