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
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">
-
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 Mar 23, 2020 at 9:41 -
-
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 Mar 23, 2020 at 11:36 -
-
thanks again first time i didn't understand your answer because i am newbie odoo developer ... thanks again Mar 23, 2020 at 12:48
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>