[IMP] updating doc for new user keyword

bzr revid: mat@openerp.com-20130621111116-2vls38to6ds72421
This commit is contained in:
Martin Trigaux
2013-06-21 13:11:16 +02:00
parent bb548a1d4e
commit 2c85b5a006
@@ -58,25 +58,25 @@ To be able to compute the number of lines, the model containing groceries is req
<field name="field_date_id" eval="ref('groceries.field_groceries_item_shopping_day')" />
</record>
As we do not want to count every recorded item, we will use a domain to restrict the selection on the user (display the count only for the items the users has bought) and the state (only the items whose list is confirmed are included). The user restriction is made with the keyword ``user_id`` in the domain and should correspond to a many2one field with the relation ``res.users``. During the evaluation, it is replaced by the user ID of the linked goal.
As we do not want to count every recorded item, we will use a domain to restrict the selection on the user (display the count only for the items the users has bought) and the state (only the items whose list is confirmed are included). The user restriction is made with the keyword ``user`` in the domain and should correspond to a many2one field with the relation ``res.users``. During the evaluation, it is replaced by the user of the linked goal. As we need the user ID of, we user ``user.id``.
::
<record model="gamification.goal.type" id="type_groceries_nbr_items">
...
<field name="domain">[('shopper_id', '=', user_id), ('list_id.state', '=', 'confirmed')]</field>
<field name="domain">[('shopper_id', '=', user.id), ('list_id.state', '=', 'confirmed')]</field>
</record>
An action can also be defined to help users to quickly reach the screen where they will be able to modify their current value. This is done by adding the XML ID of the ir.action we want to call. In our example, we would like to open the grocery list form view owned by the user.
If we do not specify a res_id to the action, only the list of records can be displayed. The restriction is done with the field ``res_id_field`` containing the field name of the user profile containing the required id. In our example, we assume the res.users model has been extended with a many2one field ``groceries_list`` to the model ``groceries.list``.
If we do not specify a res_id to the action, only the list of records can be displayed. The restriction is done with the field ``res_id_field`` containing the field name from the user profile containing the required id. The parsing mechanism is the same as for the domain of a goal, using the keyword 'user' that wil lbe replaced by the current user. In our example, we assume the res.users model has been extended with a many2one field ``groceries_list`` to the model ``groceries.list``.
::
<record model="gamification.goal.type" id="type_groceries_nbr_items">
...
<field name="action_id">groceries.action_groceries_list_form</field>
<field name="res_id_field">groceries_list.id</field>
<field name="res_id_field">user.groceries_list.id</field>
</record>