【问题标题】:How to remove the delete button from the calendar wizard in Odoo 10?如何从 Odoo 10 的日历向导中删除删除按钮?
【发布时间】:2017-11-05 11:51:27
【问题描述】:

我正在使用 Odoo10。如果我转到 Sales > Lead > Meeting Button 并单击会议按钮,则会打开日历视图。您也可以通过在日历中创建会议来打开视图。弹窗使用的模型是calendar.event

这些按钮出现在向导中:“保存”、“删除”、“取消”。该向导不包含标准视图中“删除”按钮的代码。

那么我怎样才能删除该弹出窗口中的“删除”按钮?

【问题讨论】:

    标签: python-2.7 calendar odoo-8 odoo-10 odoo


    【解决方案1】:

    我已经检查过该按钮是由 JavaScript 创建的。您只需要覆盖该方法。关注Odoo documentation guidelines。使用extendinclude 覆盖它

    var CalendarView = View.extend({
    
    // [...]
    
        open_event: function(id, title) {
            var self = this;
            if (! this.open_popup_action) {
                var index = this.dataset.get_id_index(id);
                this.dataset.index = index;
                if (this.write_right) {
                    this.do_switch_view('form', { mode: "edit" });
                } else {
                    this.do_switch_view('form', { mode: "view" });
                }
            }
            else {
                new form_common.FormViewDialog(this, {
                    res_model: this.model,
                    res_id: parseInt(id).toString() === id ? parseInt(id) : id,
                    context: this.dataset.get_context(),
                    title: title,
                    view_id: +this.open_popup_action,
                    readonly: true,
                    buttons: [
                        {text: _t("Edit"), classes: 'btn-primary', close: true, click: function() {
                            self.dataset.index = self.dataset.get_id_index(id);
                            self.do_switch_view('form', { mode: "edit" });
                        }},
    
                        {text: _t("Delete"), close: true, click: function() {
                            self.remove_event(id);
                        }},
    
                        {text: _t("Close"), close: true}
                    ]
                }).open();
            }
            return false;
        },
    

    所以我认为如果你删除 these lines 就足够了:

    {text: _t("Delete"), close: true, click: function() {
        self.remove_event(id);
    }},
    

    顺便说一下,在最后一个链接中可以看到,要修改(通过继承)的文件是addons/web_calendar/static/src/js/web_calendar.js

    【讨论】:

    • 非常感谢 chesuCR... 我会检查一次并更新你
    猜你喜欢
    • 1970-01-01
    • 2019-03-22
    • 2021-10-16
    • 1970-01-01
    • 2014-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多