diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index de9802c5688..dfd71867687 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -185,8 +185,9 @@ class gamification_goal(osv.Model): If a goal reaches the target value, the status is set to reached If the end date is passed (at least +1 day, time not considered) without the target value being reached, the goal is set as failed.""" + if context is None: context = {} - for goal in self.browse(cr, uid, ids, context=context or {}): + for goal in self.browse(cr, uid, ids, context=context): if goal.state in ('draft', 'canceled'): # skip if goal draft or canceled continue diff --git a/addons/gamification/res_users.py b/addons/gamification/res_users.py index b4f1c9c8c29..4e87ce88180 100644 --- a/addons/gamification/res_users.py +++ b/addons/gamification/res_users.py @@ -44,10 +44,13 @@ class res_users_gamification_group(osv.Model): vals['goals'].append({ 'id': goal.id, 'type_name': goal.type_id.name, + 'type_condition': goal.type_id.condition, 'type_description': goal.type_description, 'state': goal.state, 'completeness': goal.completeness, 'computation_mode': goal.computation_mode, + 'current': goal.current, + 'target_goal': goal.target_goal, }) # skip plans where all goal are done or failed if not all_done: diff --git a/addons/gamification/static/src/css/goal.css b/addons/gamification/static/src/css/goal.css index 52d90152d6a..443455a20a7 100644 --- a/addons/gamification/static/src/css/goal.css +++ b/addons/gamification/static/src/css/goal.css @@ -31,7 +31,7 @@ position: relative; display: inline-block; vertical-align: top; - width: 220px; + width: 250px; } .openerp .oe_user_sidebar .oe_gamification_goal { background: #EDEDF6; @@ -57,12 +57,18 @@ .openerp .oe_mail_wall .oe_user_sidebar ul { list-style-type: none; padding-left: 20px; + margin-bottom: 10px; +} +.openerp .oe_mail_wall .oe_user_sidebar li { + margin-bottom: 10px; } - .openerp .oe_mail_wall .oe_user_sidebar li progress { width: 80%; display: inline-block; } +.openerp .oe_mail_wall .oe_user_sidebar li p { + margin:5px 0; +} .openerp .oe_mail_wall .oe_mail { display: inline-block; } \ No newline at end of file diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 2820666d56d..667f856059e 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -3,18 +3,26 @@ openerp.gamification = function(instance) { instance.Side_bar = instance.mail.Widget.include( { init: function (parent, action) { - console.log("Init function"); var self = this; this._super(parent, action); this.deferred = $.Deferred(); this.res_user = new instance.web.DataSetSearch(this, 'res.users'); this.goals_info = {}; - console.log("init"); + }, + events: { + 'click a.oe_update_goal': function(event) { + var self = this; + var goal_id = parseInt(event.target.id); + console.log(goal_id); + var goal_updated = new instance.web.Model('gamification.goal').call('update', [[goal_id]]); + $.when(goal_updated).done(function() { + self.get_goal_todo_info(); + }); + } }, renderElement: function() { var self = this; this._super.apply(this, arguments); - console.log("Render!"); self.render_template(self.$el.filter(".oe_user_sidebar"),'user_wall'); self.get_goal_todo_info(); }, @@ -28,6 +36,7 @@ openerp.gamification = function(instance) { }, get_goal_todo_info: function() { var self = this; + console.log(this); var goals_info = this.res_user.call('get_goals_todo_info', {}).then(function(res) { self.goals_info['info'] = res }); @@ -38,5 +47,13 @@ openerp.gamification = function(instance) { } }); }, + update_goal: function() { + console.log(this); + console.log(instance.Side_bar); + var goal_update = new instance.web.Model('gamification.goal').call('update', [[parseInt(this.id)]]); + $.when(goal_update).done(function() { + // $(".oe_user_sidebar").find(".oe_gamification_goal").html(instance.web.qweb.render('goal_list_to_do')); + }); + }, }); }; diff --git a/addons/gamification/static/src/xml/gamification.xml b/addons/gamification/static/src/xml/gamification.xml index 64568403ab8..c47e5896a83 100644 --- a/addons/gamification/static/src/xml/gamification.xml +++ b/addons/gamification/static/src/xml/gamification.xml @@ -19,10 +19,17 @@

-

- - done! - +

+ + + + + (less than ) + + + update + +