2
votes

I am working with Odoo10. If I go to Sales > Lead > Meeting Button and I click on the meeting button the calendar view is opened. You can open the view by creating a meeting in the calendar as well. The model used by the popup window is calendar.event.

These buttons appear in the wizard: "Save", "Delete", "Cancel". The wizard does not contain the code of "Delete" button in the standard view.

So how can I remove the "Delete" button in that popup?

1

1 Answers

2
votes

I have checked that the button is created by JavaScript. You just need to override the method. Follow the Odoo documentation guidelines. Use extend or include to override it

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;
    },

So I think if you remove these lines would be enough:

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

By the way, as you can see in the last link, the file to modify (by inheritance) is addons/web_calendar/static/src/js/web_calendar.js