[ADD] res_id_field for specific res_id
bzr revid: mat@openerp.com-20130402134501-96uhx58u2s1gx129
This commit is contained in:
@@ -79,8 +79,11 @@ class gamification_goal_type(osv.Model):
|
||||
'sequence': fields.integer('Sequence',
|
||||
help='Sequence number for ordering',
|
||||
required=True),
|
||||
|
||||
'action_id': fields.char("Action",
|
||||
help="The action xml id that will be called to update the goal value.")
|
||||
help="The action xml id that will be called to update the goal value."),
|
||||
'res_id_field': fields.char("id field",
|
||||
help="The field name on the user profile containing the value for res_id for action")
|
||||
}
|
||||
|
||||
_order = 'sequence'
|
||||
@@ -323,8 +326,14 @@ class gamification_goal(osv.Model):
|
||||
try:
|
||||
model, xml_id = goal.type_id.action_id.split('.', 1)
|
||||
action = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid, model, xml_id, context=context)
|
||||
action['res_id'] = uid
|
||||
action['context'] = context
|
||||
|
||||
if goal.type_id.res_id_field:
|
||||
current_user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
||||
field_names = goal.type_id.res_id_field.split('.')
|
||||
res = current_user.__getitem__(field_names[0])
|
||||
for field_name in field_names[1:]:
|
||||
res = res.__getitem__(field_name)
|
||||
action['res_id'] = res
|
||||
return action
|
||||
except ValueError:
|
||||
_logger.warning("Invalid XML ID '%s' for goal action.", goal.type_id.action_id)
|
||||
|
||||
@@ -10,14 +10,16 @@
|
||||
<field name="model_id" eval="ref('base.model_res_users')" />
|
||||
<field name="domain">[('id','=',user_id),('partner_id.tz', '!=', False)]</field>
|
||||
<field name="action_id">base.action_res_users_my</field>
|
||||
<field name="res_id_field">id</field>
|
||||
</record>
|
||||
|
||||
<record model="gamification.goal.type" id="type_base_avatar">
|
||||
<field name="name">Change of avatar</field>
|
||||
<field name="description">In your user perference</field>
|
||||
<field name="computation_mode">manually</field>
|
||||
<field name="action_id">base.action_res_users_my</field>
|
||||
<!-- problem : default avatar != False -> manually + check in write function -->
|
||||
<field name="action_id">base.action_res_users_my</field>
|
||||
<field name="res_id_field">id</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -28,6 +30,7 @@
|
||||
<field name="model_id" eval="ref('base.model_res_company')" />
|
||||
<field name="domain">[('user_ids', 'in', user_id),('website', '!=', 'www.yourcompany.com')]</field>
|
||||
<field name="action_id">base.action_res_company_form_my</field>
|
||||
<field name="res_id_field">company_id.id</field>
|
||||
</record>
|
||||
|
||||
<record model="gamification.goal.type" id="type_base_company_logo">
|
||||
@@ -36,6 +39,7 @@
|
||||
<field name="model_id" eval="ref('base.model_res_company')" />
|
||||
<field name="domain">[('user_ids', 'in', user_id),('logo', '!=', False)]</field>
|
||||
<field name="action_id">base.action_res_company_form_my</field>
|
||||
<field name="res_id_field">company_id.id</field>
|
||||
</record>
|
||||
|
||||
<record model="gamification.goal.type" id="type_base_invite">
|
||||
|
||||
Reference in New Issue
Block a user