当我在 odoo(openERP7) qweb 屏幕中使用 self.do_action 重定向我的页面时,数据表未加载

Data Tables are not loading when i redirect my page using self.do_action in odoo(openERP7) qweb screen

当我在 odoo(openERP7) 中使用 self.do_action 重定向我的页面时,它没有在新页面中加载数据表。 在其他页面上它工作正常。但是在特定页面中,如果我使用此重定向 self.do_action 则不起作用。但是 self.act_window 在同一页面上工作正常。

如果有人遇到同样的问题,请告诉我。

更新:我在我的代码中发现了相似的问题。我有一个像 performance.review 这样的模型,还有一些其他模型。此模型中使用的所有 self.do_action 均未正确加载数据表。但其他型号的屏幕效果很好。 模型扩展和使用 self.do_action 之间有什么关系吗? 这是我的代码,

module.ReviewForm= instance.web.Widget.extend({
    events: {
        'click #review_tree_view':'load_tree_view',
    },

load_tree_view: function (event) {
        var self = this;
        self.do_action({
            type: 'ir.actions.client',
            tag: "performance.review",
            name:'Tree view',
            target: 'current',
        });
    },

在 javascript 文件中,您可以将事件添加到按钮 class 名称中,如下所示:

bind_events: function () {            
        this.$('.oe_btn_class_name').on('click', this.on_call_new_view_function);
    },

然后 "on_call_new_view_function" 在点击事件发生时调用并打开新视图,如下所示:

on_call_new_view_function: function () {
        var self = this;
        // you can pass in other data using the context dictionary variable
        var context = {
            'id': this.id,
        };
        // the action dictionary variable sends data in the "self.do_action" method
        var action = {
                type: 'ir.actions.act_window',
                res_model: 'model.name',
                view_id: 'view_id',
                view_mode: 'form',
                view_type: 'form',
                views: [[false, 'form']],
                target: 'new',
                context: context,
        };
        // self.do_action accepts the action parameter and opens the new view
        self.do_action(action);
    },

其实这是我自己犯的一个小错误。我对许多 qweb 屏幕使用相同的模型,并且每次我使用 self.do_action 渲染表单视图时我都没有清空现有的树视图。

加上这一行就可以轻松搞定。 现在数据表加载正确且完美。

load_tree_view: function (event) {
    var self = this;

    self.$el.empty();

    self.do_action({
        type: 'ir.actions.client',
        tag: "performance.review",
        name:'Tree view',
        target: 'current',
    });
},