通过从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',
}
但它并不令人耳目一新。我能做什么?
您只是在告诉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');
....
....
....
我不知道正确的语法。希望你明白
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句