1

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

2 Answers 2

1

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">
8
  • i added <attribute name="group_edit">false</attribute> it just disable editing record in kanban view but can't disable drag and drop cards in kanban view .. i added your js code and include it's file in template web.assets_backend but has no effect
    – omar ahmed
    Mar 23, 2020 at 9:41
  • Did you add the sortable attribute?
    – Kenly
    Mar 23, 2020 at 9:57
  • yes <attribute name="sortable">false</attribute> but still doesn't work i found a solution i guess you forgot to add : ``` odoo.define('kanban_draggable.kanban_column',function(require){ "use strict"; ``` it works solution
    – omar ahmed
    Mar 23, 2020 at 11:36
  • Of course, I omit to add it. I added just the relevant part.
    – Kenly
    Mar 23, 2020 at 12:21
  • thanks again first time i didn't understand your answer because i am newbie odoo developer ... thanks again
    – omar ahmed
    Mar 23, 2020 at 12:48
0

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.