[ADD] change avatar function
bzr revid: mat@openerp.com-20130329154535-a6v8shsc3igv2wiy
This commit is contained in:
@@ -343,6 +343,19 @@ class gamification_goal(osv.Model):
|
||||
|
||||
return False
|
||||
|
||||
def changed_users_avatar(self, cr, uid, ids, context):
|
||||
"""Warning a user changed his avatar.
|
||||
|
||||
The goal_type type_base_avatar requires a change of avatar. As an
|
||||
avatar is randomly generated by default, trigger warning when change.
|
||||
Set the state of every type_base_avatar linked to ids to 'reached' and
|
||||
set current value to 1.
|
||||
"""
|
||||
goal_type_id = self.pool['ir.model.data'].get_object(cr, uid, 'gamification', 'type_base_avatar', context)
|
||||
goal_ids = self.search(cr, uid, [('type_id', '=', goal_type_id.id), ('user_id', 'in', ids)], context=context)
|
||||
values = {'state': 'reached', 'current': 1}
|
||||
self.write(cr, uid, goal_ids, values, context=context)
|
||||
|
||||
|
||||
class goal_manual_wizard(osv.TransientModel):
|
||||
"""Wizard type to update a manual goal"""
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
<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
|
||||
<field name="computation_mode">count</field>
|
||||
<field name="model_id" eval="ref('base.model_res_users')" />
|
||||
<field name="field_id" eval="ref('base.field_res_partner_image')" />
|
||||
<field name="domain">[('id','=',user_id),('partner_id.image', '!=', False)]</field>
|
||||
<field name="action_id">base.action_res_users_my</field>
|
||||
-->
|
||||
</record>
|
||||
|
||||
|
||||
@@ -128,8 +128,8 @@ class gamification_goal_plan(osv.Model):
|
||||
string='State',
|
||||
required=True),
|
||||
'visibility_mode': fields.selection([
|
||||
('board','Leader board'),
|
||||
('progressbar','Personal progressbar')
|
||||
('board', 'Leader board'),
|
||||
('progressbar', 'Personal progressbar')
|
||||
],
|
||||
string="Visibility",
|
||||
help='How are displayed the results, shared or in a single progressbar',
|
||||
|
||||
@@ -20,6 +20,9 @@ class res_users_gamification_group(osv.Model):
|
||||
plan_ids = goal_plan_obj.search(cr, uid, [('autojoin_group_id', 'in', user_group_ids)], context=context)
|
||||
|
||||
goal_plan_obj.plan_subscribe_users(cr, uid, plan_ids, ids, context=context)
|
||||
|
||||
if vals.get('image'):
|
||||
self.pool.get('gamification.goal').changed_users_avatar(cr, uid, ids, context)
|
||||
return write_res
|
||||
|
||||
def get_goals_todo_info(self, cr, uid, context=None):
|
||||
|
||||
@@ -39,7 +39,9 @@ openerp.gamification = function(instance) {
|
||||
});
|
||||
$.when(goal_action).done(function() {
|
||||
var action_manager = new instance.web.ActionManager(this);
|
||||
action_manager.do_action(goal_action.action);
|
||||
action_manager.do_action(goal_action.action).done(function () {
|
||||
self.get_goal_todo_info();
|
||||
});
|
||||
|
||||
//var form = action_manager.dialog_widget.views.form.controller;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user