odoo.define('list_view_print_button_hide', function (require) {
"use strict";
var ListController = require('web.ListController');
ListController.include({
_getActionMenuItems: function (state) {
// 可以换成group_id, 设置条件, 只需要改动toolbarActions
if (this.modelName === 'stock.picking'){
this.toolbarActions.print = []
}
return this._super.apply(this, arguments);
}
})
})
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~修正~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@@@@@@@@产品模板举例
ListController.include({
init: function (parent, model, renderer, params) {
this.isActionEnable = false;
this.isPrintEnable = false;
this._super.apply(this, arguments);
},
_getActionMenuItems: function (state) {
var pros = this._super.apply(this, arguments);
if ((this.modelName === 'product.product' || this.modelName === 'product.template') && pros) {
if (!this.isActionEnable) {
pros.items.action = []
pros.items.other = []
}
if (!this.isPrintEnable) {
pros.items.print = []
}
}
return pros;
},
willStart() {
var self = this;
session.user_has_group('product_extra.group_product_action_dropdown').then(function (has_group) {
if (has_group) {
self.isActionEnable = true;
}
});
session.user_has_group('product_extra.group_product_print_dropdown').then(function (has_group) {
if (has_group) {
self.isPrintEnable = true;
}
});
return this._super.apply(this, arguments);
}
});
此篇博客介绍了如何在Odoo中定制ListController,针对product.product和product.template模型,通过条件逻辑控制stock.picking的打印按钮显示和启用。通过user_has_group方法检查特定用户组权限,实现菜单项的动态调整。
1339

被折叠的 条评论
为什么被折叠?



