在Odoo中禁用看板列视图上的拖动和排序功能 [英] Disable drag and sort features on kanban columns view in Odoo
问题描述
我正在Odoo 9中制作看板视图,以在基于Many2one字段的列中显示我的模型.
I'm making a kanban view in Odoo 9 to display my model in columns based in a Many2one field.
我已经这样创建了看板视图:
I've created my kanban view like this:
<kanban create="false" edit="false" delete="false" quick_create="false" default_group_by="resource_id">
我只希望该视图为只读,我不想编辑或创建,因为我有另一个视图可以做到这一点.就像仪表板一样.
I only want this view for read only, I don't want to edit or create because I have another view to do it. It's like a dashboard.
问题是我想禁用列的拖放和可排序功能.我看到kanban_view.js
文件在render_grouped
函数中默认设置了可排序和可拖动选项.
The problem is that I want to disable the drag and drop and sortable feature for the columns. I see that the kanban_view.js
file set the sortable and draggable options by default in the render_grouped
function.
有人知道如何禁用列的那些功能吗?或者,还有其他方法可以在看板视图中按列显示我的记录吗?
Does anyone know how to disable those features for columns? Or, is there any other way to display my records by columns in a kanban view?
推荐答案
到目前为止,尚无参数可以执行此操作.因此,在新模块中,在KanbanView上创建JS扩展,覆盖render()并在此处禁用sortable.这是Odoo 10的完整.js代码,与v9相似:
To this day, there is no parameter to do this. So in your new module, create a JS extension on KanbanView, override render() and disable the sortable there. Here is the complete .js code for Odoo 10 which should be similar for v9:
odoo.define('my_module.board', function(require) {
"use strict";
var core = require('web.core');
var KanbanView = require('web_kanban.KanbanView');
var MyBoard = KanbanView.extend({
render: function() {
this._super.apply(this, arguments);
this.$el.sortable('option', 'disabled', true);
this.$('.o_kanban_header').css('cursor', 'auto');
}
});
return MyBoard;
});
P.S .:强烈建议您不要修改Odoo基本代码,除非您不打算进行更新.
P.S.: I strongly advise against modifying Odoo base code unless you don't plan on updating.
这篇关于在Odoo中禁用看板列视图上的拖动和排序功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!