首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Odoo 10页面重新加载

Odoo 10页面重新加载
EN

Stack Overflow用户
提问于 2018-02-01 06:53:32
回答 1查看 1K关注 0票数 1

在通过从Python调用方法创建记录后,我正在尝试从自定义js按钮重新加载网页:

代码语言:javascript
复制
@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',
    }

但这并不令人耳目一新。我能做什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-01 18:53:10

您只是告诉odoo执行该方法,但他不会在客户端对返回值做任何操作:

代码语言:javascript
复制
   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');

            ....
            ....
            ....

我不知道正确的语法。希望你明白我的意思

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48552786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档