[IMP] improving the computation of res_id_field with safe eval
bzr revid: mat@openerp.com-20130621110758-zo20gjzaecv4iu41
This commit is contained in:
@@ -179,7 +179,6 @@ class gamification_goal(osv.Model):
|
||||
help="In case of manual goal, reminders are sent if the goal as not been updated for a while (defined in goal plan). Ignored in case of non-manual goal or goal not linked to a plan."),
|
||||
|
||||
'type_description': fields.related('type_id', 'description', type='char', string='Type Description', readonly=True),
|
||||
'type_suffix': fields.related('type_id', 'suffix', type='char', string='Type Description', readonly=True),
|
||||
'type_condition': fields.related('type_id', 'condition', type='char', string='Type Condition', readonly=True),
|
||||
'type_suffix': fields.related('type_id', 'full_suffix', type="char", string="Suffix", readonly=True),
|
||||
'type_display': fields.related('type_id', 'display_mode', type="char", string="Display Mode", readonly=True),
|
||||
@@ -345,12 +344,7 @@ class gamification_goal(osv.Model):
|
||||
|
||||
if goal.type_id.res_id_field:
|
||||
current_user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
# this loop manages the cases where res_id_field is a browse record path (eg : company_id.currency_id.id)
|
||||
field_names = goal.type_id.res_id_field.split('.')
|
||||
res = current_user
|
||||
for field_name in field_names[:]:
|
||||
res = res.__getitem__(field_name)
|
||||
action['res_id'] = res
|
||||
action['res_id'] = safe_eval(goal.type_id.res_id_field, {'user': current_user})
|
||||
|
||||
# if one element to display, should see it in form mode if possible
|
||||
views = action['views']
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<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" eval="ref('base.action_res_users_my')" />
|
||||
<field name="res_id_field">id</field>
|
||||
<field name="res_id_field">user.id</field>
|
||||
</record>
|
||||
|
||||
<record model="gamification.goal.type" id="type_base_avatar">
|
||||
@@ -21,7 +21,7 @@
|
||||
<field name="display_mode">checkbox</field>
|
||||
<!-- problem : default avatar != False -> manually + check in write function -->
|
||||
<field name="action_id" eval="ref('base.action_res_users_my')" />
|
||||
<field name="res_id_field">id</field>
|
||||
<field name="res_id_field">user.id</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<field name="model_id" eval="ref('base.model_res_company')" />
|
||||
<field name="domain">[('user_ids', 'in', user.id), ('name', '!=', 'Your Company')]</field>
|
||||
<field name="action_id" eval="ref('base.action_res_company_form')" />
|
||||
<field name="res_id_field">company_id.id</field>
|
||||
<field name="res_id_field">user.company_id.id</field>
|
||||
</record>
|
||||
|
||||
<record model="gamification.goal.type" id="type_base_company_logo">
|
||||
@@ -43,7 +43,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" eval="ref('base.action_res_company_form')" />
|
||||
<field name="res_id_field">company_id.id</field>
|
||||
<field name="res_id_field">user.company_id.id</field>
|
||||
</record>
|
||||
|
||||
<record id="action_new_simplified_res_users" model="ir.actions.act_window">
|
||||
|
||||
Reference in New Issue
Block a user