我试图通过从Python调用方法创建记录后从自定义js按钮重新加载网页:
@api.multi
def create_period(self):
self.create({
'name': '11',
'code': '12',
'date_start': '2018-01-01',
'date_stop': '2018-12-31',
})
return {
'type': 'ir.actions.client',
'tag': 'reload',
}
但它并不令人耳目一新。我该怎么办?
答案 0 :(得分:1)
您只是告诉odoo执行该方法,但他不会对客户端返回的值做任何事情:
render_buttons: function() {
// First of all keep track of view instance so you can reference it in callback method
var self = this;
// use self instead of this to prevent bugs
self._super.apply(this, arguments); // don't forget ";" at the end of each instruction
......
.....
// you should save the response in a variable
var result = model.call('create_period', [[]]);
// you may need to check the result first before reload
// to execute an action use do_action any widget should have this method
// try this self is the instance of tree view
self.do_action(result);
//or try this code: self.do_action('reload');
....
....
....
我不知道正确的语法。希望你明白这个想法