[IMP] better goals

bzr revid: mat@openerp.com-20130402121514-thl9b43jnbu12tr0
This commit is contained in:
Martin Trigaux
2013-04-02 14:15:14 +02:00
parent 060296a0b2
commit a3c3a07d3a
3 changed files with 17 additions and 19 deletions
+7 -7
View File
@@ -319,13 +319,6 @@ class gamification_goal(osv.Model):
:return: action description in a dictionnary
"""
goal = self.browse(cr, uid, goal_id, context=context)
action = {
'name': "Update %s" % goal.type_id.name,
'id': goal_id,
'type': 'ir.actions.act_window',
'views': [[False, 'form']],
'target': 'new',
}
if goal.type_id.action_id:
try:
model, xml_id = goal.type_id.action_id.split('.', 1)
@@ -337,6 +330,13 @@ class gamification_goal(osv.Model):
_logger.warning("Invalid XML ID '%s' for goal action.", goal.type_id.action_id)
if goal.computation_mode == 'manually':
action = {
'name': "Update %s" % goal.type_id.name,
'id': goal_id,
'type': 'ir.actions.act_window',
'views': [[False, 'form']],
'target': 'new',
}
action['context'] = {'default_goal_id': goal_id, 'default_current': goal.current}
action['res_model'] = 'gamification.goal.wizard'
return action
+4 -6
View File
@@ -26,23 +26,21 @@
<field name="description">Specify at least a website</field>
<field name="computation_mode">count</field>
<field name="model_id" eval="ref('base.model_res_company')" />
<field name="domain">[(user_id, 'in', 'user_ids'),('website', '!=', 'www.yourcompany.com')]</field>
<field name="action_id">base.action_res_company_form</field>
<field name="domain">[('user_ids', 'in', user_id),('website', '!=', 'www.yourcompany.com')]</field>
<field name="action_id">base.action_res_company_form_my</field>
</record>
<record model="gamification.goal.type" id="type_base_company_logo">
<field name="name">Change your company logo</field>
<field name="computation_mode">manually</field>
<field name="computation_mode">count</field>
<field name="model_id" eval="ref('base.model_res_company')" />
<field name="domain">[(user_id, 'in', 'user_ids'),('logo', '!=', False)]</field>
<field name="action_id">base.action_res_company_form</field>
<field name="domain">[('user_ids', 'in', user_id),('logo', '!=', False)]</field>
<field name="action_id">base.action_res_company_form_my</field>
</record>
<record model="gamification.goal.type" id="type_base_invite">
<field name="name">Invite new users</field>
<field name="description">Create at least another user</field>
<field name="computation_mode">manually</field>
<field name="computation_mode">count</field>
<field name="model_id" eval="ref('base.model_res_users')" />
<field name="domain">[('id', '!=', user_id)]</field>
@@ -13,7 +13,7 @@ openerp.gamification = function(instance) {
events: {
'click a.oe_update_goal': function(event) {
var self = this;
var goal_id = parseInt(event.currentTarget.id);
var goal_id = parseInt(event.currentTarget.id, 10);
var goal_updated = new instance.web.Model('gamification.goal').call('update', [[goal_id]]);
$.when(goal_updated).done(function() {
self.get_goal_todo_info();
@@ -21,7 +21,7 @@ openerp.gamification = function(instance) {
},
'click a.oe_update_plan': function(event) {
var self = this;
var plan_id = parseInt(event.currentTarget.id);
var plan_id = parseInt(event.currentTarget.id, 10);
var goals_updated = new instance.web.Model('gamification.goal.plan').call('quick_update', [plan_id]);
$.when(goals_updated).done(function() {
self.get_goal_todo_info();
@@ -33,7 +33,7 @@ openerp.gamification = function(instance) {
// },
'click a.oe_goal_action': function(event) {
var self = this;
var goal_id = parseInt(event.currentTarget.id);
var goal_id = parseInt(event.currentTarget.id, 10);
var goal_action = new instance.web.Model('gamification.goal').call('get_action', [goal_id]).then(function(res) {
goal_action['action'] = res;
});
@@ -45,7 +45,7 @@ openerp.gamification = function(instance) {
//var form = action_manager.dialog_widget.views.form.controller;
});
},
}
},
renderElement: function() {
var self = this;
@@ -63,7 +63,7 @@ openerp.gamification = function(instance) {
get_goal_todo_info: function() {
var self = this;
var goals_info = this.res_user.call('get_goals_todo_info', {}).then(function(res) {
self.goals_info['info'] = res
self.goals_info['info'] = res;
});
$.when(goals_info).done(function() {
if(self.goals_info.info.length > 0){
@@ -87,7 +87,7 @@ openerp.gamification = function(instance) {
});
money_field.set('currency', currency_id);
money_field.get_currency_info();
money_field.set('value', parseInt($(this).text()));
money_field.set('value', parseInt($(this).text(), 10));
money_field.replace($(this));
});
},