omar ahmed
omar ahmed

Reputation: 663

Disable drag drop record in kanban odoo12

i want the user to only view the opportunities by its stages in kanban view and not to change the stages ? And disable sorting columns (stages) All solutions i found for other versions 7 , 10 and 13 not odoo version12

Upvotes: 1

Views: 2237

Answers (2)

m3asmi
m3asmi

Reputation: 1262

you can stop that by modifying the attribute of stage_id for example

<field name="stage_id" position="attributes">
    <attribute name="readonly">True</attribute>
</field>

Upvotes: 0

Kenly
Kenly

Reputation: 26698

According to kanban view documentation, to disable editing stages you can set group_edit option to false on kanban tag.

<kanban ... group_edit="false">

To disable column sorting I did not find an option, it seems that the renderer (_renderGrouped) only checks if the stage field is of type many2one, so I added a new option to enable or disable column sorting.

var KanbanRenderer = require('web.KanbanRenderer');

KanbanRenderer.include({

    _setState: function (state) {
        var self = this;
        this._super(state);
        if (this.arch.attrs.sortable) {
            this.columnOptions = _.extend(self.columnOptions, {
                sortable: this.arch.attrs.sortable === 'true',
            });
        }

        if (this.arch.attrs.disable_drag_drop_record) {
            if (this.arch.attrs.disable_drag_drop_record=='true') {
                this.columnOptions.draggable = false;
            }
        }
    },

    _renderGrouped: function (fragment) {
        this._super.apply(this, arguments);
        if (this.columnOptions.sortable===false) {
            // remove previous sorting
            this.$el.sortable('destroy');
        }
    },

});

Set sortable attribute to false in kanban view:

<kanban ... sortable="false" disable_drag_drop_record="true">

Upvotes: 1

Related Questions