在弹出窗口中显示要删除的项目 [英] Show to be deleted items in popup window

查看:88
本文介绍了在弹出窗口中显示要删除的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Odoo 10e.我想要一种简单的功能,只要我想从列表视图或仅从特定列表视图中删除一项或多项,然后删除一项即可.我想显示所有要删除的项目,以便在弹出窗口中显示其名称,以便用户可以快速查看要删除的内容.我知道用户可以在列表视图中看到详细信息,但是我想以模型窗口的形式向用户瞥一眼,这将被删除.您确定要删除吗?

I am using Odoo 10e. I want a simple functionality that whenever i wanted to delete one or more then one item from a list view or from a specific list view only. I want to show all of the items which are selected for deleted to show their name in popup window so that user can have a quick review what's he is going to delete. I know user can see details in list view but i want to give a glimpse to user in shape of model window that this is going to be deleted. Are you sure to delete ?

如果用户单击确认",则正常的删除情况将起作用.

If user click Confirm then normal delete case should work.

到目前为止,我一直在研究和研究它,我认为这应该与重写Web模块中list_view.js中的do_delete方法有关.但是我对Odoo的javascript覆盖了解不多.

As far i research and worked on it, i have idea that it should be something regarding overriding the do_delete method in the list_view.js in the web module. But i didn't know much about javascript overriding for Odoo.

推荐答案

这是我如何执行此操作的示例.

This is an example how I do it.

我为您的模型调用了name_get并记录了ID,此名称列表中,我用选择的ID信息更改确认消息的文本.

I called the name_get for your model and records ids, this names list, I change the text of confirming message with the information of ids selected.

do_delete: function (ids) {

    new Model(this.model)
    .call('name_get', [ids, this.dataset.get_context()]).done(function (names) {


        var text = _t("Do you really want to remove these records?") + ' '+ names.join(' \n')
        if (!(ids.length && confirm(text))) {
            return;
        }
        var self = this;

        return $.when(this.dataset.unlink(ids)).done(function () {
            _(ids).each(function (id) {
                self.records.remove(self.records.get(id));
            });
            // Hide the table if there is no more record in the dataset
            if (self.display_nocontent_helper()) {
                self.no_result();
            } else {
                if (self.records.length && self.current_min === 1) {
                    // Reload the list view if we delete all the records of the first page
                    self.reload();
                } else if (self.records.length && self.dataset.size() > 0) {
                    // Load previous page if the current one is empty
                    self.pager.previous();
                }
                // Reload the list view if we are not on the last page
                if (self.current_min + self._limit - 1 < self.dataset.size()) {
                    self.reload();
                }
            }
            self.update_pager(self.dataset);
            self.compute_aggregates();
        });
    });;
},

这篇关于在弹出窗口中显示要删除的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆