diff options
| author | Thibault Delavallée <tde@openerp.com> | 2012-04-02 10:18:26 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2012-04-02 10:18:26 +0200 |
| commit | 8c2b07bf7633b5c07b6b8e17b68530833f8cd406 (patch) | |
| tree | 3940aa6e118037405c94a168e66d73beed04011d /doc/api | |
| parent | 5fd95c5769309bac7286308a79e633025a87b89b (diff) | |
[REF] Cleaned ir.needaction code and documentation.
bzr revid: tde@openerp.com-20120402081826-016k0ecbjz3fqnps
Diffstat (limited to 'doc/api')
| -rw-r--r-- | doc/api/need_action_specs.rst | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/doc/api/need_action_specs.rst b/doc/api/need_action_specs.rst index 8efd548845a..a2829b7873a 100644 --- a/doc/api/need_action_specs.rst +++ b/doc/api/need_action_specs.rst @@ -4,18 +4,18 @@ Need action mechanism base.needaction mixin class +++++++++++++++++++++++++++ -This revision adds a mixin class for objects using the need action feature. 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. - +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 table (base.needaction_users_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. 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,: - - ``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). - - ``needaction_get_record_ids``: for a given model_name 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_record_ids``: for a given model_name 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) - -A menu in Settings/Users has been added to allow having a quick look to need_action_user_ids. + - ``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) Menu modification +++++++++++++++++ @@ -37,9 +37,9 @@ In your ``foo`` module, you want to specify that when it is in state ``confirmed _inherit = [base.needaction] [...] def get_needaction_user_ids(self, cr, uid, ids, context=None): - # set the list void by default result = dict.fromkeys(ids) for foo_obj in self.browse(cr, uid, ids, context=context): + # set the list void by default result[foo_obj.id] = [] # if foo_obj is confirmed: manager is required to perform an action if foo_obj.state == 'confirmed': |
