[FIX] call correct method for cron

bzr revid: mat@openerp.com-20130324134658-0kx6v1st048gkm1r
This commit is contained in:
Martin Trigaux 2013-03-24 14:46:58 +01:00
parent 632a9d4bcb
commit 02725e359d
4 changed files with 66 additions and 4 deletions

View File

@ -20,7 +20,7 @@
<field name="numbercall">-1</field>
<field eval="False" name="doall" />
<field name="model">gamification.badge</field>
<field name="function">check_automatic</field>
<field name="function">_cron_check</field>
<field name="args">()</field>
</record>
</data>

View File

@ -304,3 +304,37 @@ class gamification_goal(osv.Model):
plan_obj = self.pool.get('gamification.goal.plan')
plan_obj.report_progress(cr, uid, goal.plan_id, users=[goal.user_id], context=context)
return super(gamification_goal, self).write(cr, uid, ids, vals, context=context)
def get_action(self, cr, uid, goal_id, context=None):
"""Get the ir.action related to update the goal
In case of a manual goal, should return a wizard to update the value
:return: dict like
{
'name':'Action name',
'id': goal_id,
'type': 'ir.actions.act_window',
'res_model': goal.type_id.model_id,
'view': 'form',
}
"""
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',
}
if goal.computation_mode == 'manually':
action['res_model'] = 'gamification.goal.wizard'
else:
action['res_model'] = goal.type_id.model_id # TOCHECK
return action
class goal_manual_wizard(osv.TransientModel):
"""Wizard type to update a manual goal"""
_name = 'gamification.goal.wizard'
_columns = {
'goal_id': fields.many2one("gamification.goal", string='Goal'),
'current': fields.text('Current'),
}

View File

@ -24,6 +24,34 @@ openerp.gamification = function(instance) {
var goal_id = parseInt(event.currentTarget.id);
this.$el.find('.oe_type_description_'+goal_id).toggle(10);
},
'click a.oe_goal_action': function(event) {
var self = this;
var goal_id = parseInt(event.currentTarget.id);
var goal_action = new instance.web.Model('gamification.goal').call('get_action', [goal_id]);
console.log(goal_action);
// var action = {
// name : 'Complete Profile',
// type: 'ir.actions.act_window',
// res_model: 'res.users',
// views: [[false, 'form']],
// res_id : event.data.uid,
// target: 'new',
// flags : { action_buttons: true },
// };
// var action_manager = new instance.web.ActionManager(this);
// action_manager.do_action(action);
// var form = action_manager.dialog_widget.views.form.controller;
// form.on('load_record', self, function(){
// form.fields[$(self).attr('id')].$el.find("input").focus()
// })
// form.on("on_button_cancel", action_manager.dialog, action_manager.dialog.close);
// form.on('save', self, function() {
// action_manager.dialog.close();
// location.reload();
// });
}
},
renderElement: function() {
var self = this;

View File

@ -7,9 +7,9 @@
<h3><t t-esc="plan.name"/></h3>
<ul class="oe_goals_list">
<li t-foreach="plan.goals" t-as="goal">
<strong t-attf-class="#{goal.state == 'reached' ? 'oe_goal_reached' : goal.state == 'failed' ? 'oe_goal_failed' : ''}">
<t t-esc="goal.type_name" />
</strong>
<a class="oe_goal_action" t-att-id="goal.id">
<strong t-attf-class="#{goal.state == 'reached' ? 'oe_goal_reached' : goal.state == 'failed' ? 'oe_goal_failed' : ''}"><t t-esc="goal.type_name" /></strong>
</a>
<t t-if="goal.type_description">
<a class="oe_show_description" t-att-id="goal.id">?</a>
<p t-att-class="'oe_type_description oe_type_description_' + goal.id"><t t-esc="goal.type_description" /></p>