[IMP] on change, doc and catergory

bzr revid: mat@openerp.com-20130423155532-yxqq2nchuaeyxste
This commit is contained in:
Martin Trigaux 2013-04-23 17:55:32 +02:00
parent 99505e351d
commit 006a266396
8 changed files with 29 additions and 19 deletions

View File

@ -22,7 +22,7 @@
'name': 'Gamification',
'version': '1.0',
'author': 'OpenERP SA',
'category': 'Human Resources',
'category': 'Human Ressources',
'depends': ['mail'],
'description': """
Gamification process

View File

@ -1,15 +1,15 @@
How to create new goal plan for my addon
How to create new challenge for my addon
========================================
Running example
+++++++++++++++
A module to create and manage groceries lists has been developped. To motivate users to use it, a goal plan is developped. This how to will explain the creation of a dedicated module and the XML file for the required data.
A module to create and manage groceries lists has been developped. To motivate users to use it, a challenge (gamification.goal.plan) is developped. This how to will explain the creation of a dedicated module and the XML file for the required data.
Module
++++++
The goal plan for my addon will consist of an auto-installed module containing only the definition of goals. Goal type are quite technical to create and should not be seen or modified through the web interface.
The challenge for my addon will consist of an auto-installed module containing only the definition of goals. Goal type are quite technical to create and should not be seen or modified through the web interface.
If our groceries module is called ``groceries``, the structure will be consisted of three addons :
@ -58,13 +58,13 @@ 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 will be buying) 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. 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_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.
::
<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.
@ -83,14 +83,10 @@ If we do not specify a res_id to the action, only the list of records can be dis
Plan definition
++++++++++++++++
Once all the goal types are defined, a goal plan can be created. In our example, we would like to create a plan "Discover the Groceries Module" with simple tasks applied to every new user in the group ``groceries.shoppers_group``. This goal plan should only be applied once by user so no recurring date is selected.
Once all the goal types are defined, a challenge (or goal plan) can be created. In our example, we would like to create a plan "Discover the Groceries Module" with simple tasks applied to every new user in the group ``groceries.shoppers_group``. This goal plan should only be applied once by user and with no ending period, no dates or peridocity is then selected. The goal will be started manually but specifying a value to ``start_date`` can make it start automatically.
::
<record model="gamification.goal.planline" id="planline_groceries_discover1">
<field name="type_id" eval="ref('type_groceries_nbr_items')" />
<field name="target_goal">3</field>
</record>
<record model="gamification.goal.plan" id="plan_groceries_discover">
<field name="name">Discover the Groceries Module</field>
<field name="period">once</field>
@ -98,10 +94,14 @@ Once all the goal types are defined, a goal plan can be created. In our example,
<field name="report_message_frequency">never</field>
<field name="planline_ids" eval="[(4, ref('planline_groceries_discover1'))]"/>
<field name="autojoin_group_id" eval="ref('groceries.shoppers_group')" />
<field name="start_date" eval="(DateTime.today() - timedelta(days=1)).strftime('%Y-%m-%d')"/>
<!-- setting start date to yesterday allows automatic start at module installation -->
</record>
To add goal types to a plan, planlines must be created. The value to reach is defined for a planline, this will be the ``target_goal`` for each goal generated.
::
<record model="gamification.goal.planline" id="planline_groceries_discover1">
<field name="type_id" eval="ref('type_groceries_nbr_items')" />
<field name="target_goal">3</field>
<field name="plan_id" eval="ref('plan_groceries_discover')" />
</record>

View File

@ -157,7 +157,7 @@ class gamification_goal(osv.Model):
if not type_id:
return {'value': {'type_id': False}}
goal_type = goal_type.browse(cr, uid, type_id, context=context)
ret = {'value': {'computation_mode': goal_type.computation_mode}}
ret = {'value': {'computation_mode': goal_type.computation_mode, 'type_condition': goal_type.condition}}
return ret
_columns = {

View File

@ -79,7 +79,7 @@
<div>
<field name="current" class="oe_inline"/>
<button string="refresh" type="object" name="update" class="oe_link" attrs="{'invisible':['|',('computation_mode', '=', 'manually'),('state', '=', 'draft')]}" />
<div class="oe_grey">
<div class="oe_grey" attrs="{'invisible':[('type_id', '=', False)]}">
Reached when current value is <strong><field name="type_condition" class="oe_inline"/></strong> than the target.
</div>
</div>

View File

@ -757,6 +757,16 @@ class gamification_goal_planline(osv.Model):
result[p_id] = True
return result.keys()
def on_change_type_id(self, cr, uid, ids, type_id=False, context=None):
goal_type = self.pool.get('gamification.goal.type')
if not type_id:
return {'value': {'type_id': False}}
goal_type = goal_type.browse(cr, uid, type_id, context=context)
ret = {'value': {
'type_condition': goal_type.condition,
'type_full_suffix': goal_type.full_suffix}}
return ret
_columns = {
'name': fields.related('type_id', 'name', string="Name"),
'plan_id': fields.many2one('gamification.goal.plan',

View File

@ -75,7 +75,7 @@
<field name="planline_ids" nolabel="1" colspan="4">
<tree string="Planline List" version="7.0" editable="bottom" >
<field name="sequence" widget="handle"/>
<field name="type_id"/>
<field name="type_id" on_change="on_change_type_id(type_id)" />
<field name="type_condition"/>
<field name="target_goal"/>
<field name="type_full_suffix"/>

View File

@ -22,7 +22,7 @@
'name': 'CRM Gamification',
'version': '1.0',
'author': 'OpenERP SA',
'category': 'CRM',
'category': 'hidden',
'depends': ['gamification','sale_crm'],
'description': """Example of goal types and plans that can be used related to the usage of the CRM Sale module.""",

View File

@ -22,7 +22,7 @@
'name': 'HR Gamification',
'version': '1.0',
'author': 'OpenERP SA',
'category': 'HR',
'category': 'hidden',
'depends': ['gamification', 'hr'],
'description': """Use the HR ressources for the gamification process.