机企猫 隐藏项目模块修改接入(可隐藏导出、新建等项目)
This commit is contained in:
46
jikimo_hide_options/static/src/js/form_controller.js
Normal file
46
jikimo_hide_options/static/src/js/form_controller.js
Normal file
@@ -0,0 +1,46 @@
|
||||
/** @odoo-module */
|
||||
/**
|
||||
* This file will used to hide the selected options from the form view
|
||||
*/
|
||||
import { FormController} from "@web/views/form/form_controller";
|
||||
import { patch} from "@web/core/utils/patch";
|
||||
var rpc = require('web.rpc');
|
||||
const { onWillStart} = owl;
|
||||
patch(FormController.prototype, 'jikimo_hide_options/static/src/js/form_controller.js.FormController', {
|
||||
/**
|
||||
* This function will used to hide the selected options from the form view
|
||||
*/
|
||||
setup() {
|
||||
this._super();
|
||||
onWillStart(async () => {
|
||||
var self = this
|
||||
var result;
|
||||
await rpc.query({
|
||||
model: 'access.right',
|
||||
method: 'hide_buttons',
|
||||
}).then(function(data) {
|
||||
result = data;
|
||||
});
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
var group = result[i].module + "." + result[i].group_name
|
||||
if (self.props.resModel == result[i].model) {
|
||||
if (await self.user.hasGroup(group)) {
|
||||
if (!this.user.isAdmin) {
|
||||
if (result[i].is_create_or_update) {
|
||||
self.canCreate = false
|
||||
}
|
||||
if (result[i].is_delete) {
|
||||
this.archInfo.activeActions.delete = false
|
||||
}
|
||||
if (result[i].is_archive) {
|
||||
self.archiveEnabled = false
|
||||
} else {
|
||||
self.archiveEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
42
jikimo_hide_options/static/src/js/kanban_controller.js
Normal file
42
jikimo_hide_options/static/src/js/kanban_controller.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/** @odoo-module */
|
||||
/**
|
||||
* This file will used to hide the selected options from the list view
|
||||
*/
|
||||
import { KanbanController } from '@web/views/kanban/kanban_controller';
|
||||
import { patch} from "@web/core/utils/patch";
|
||||
var rpc = require('web.rpc');
|
||||
const {onWillStart} = owl;
|
||||
patch(KanbanController.prototype, 'jikimo_hide_options/static/src/js/list_controller.js.KanbanController', {
|
||||
/**
|
||||
* This function will used to hide the selected options from the Kanban view
|
||||
*/
|
||||
setup() {
|
||||
this._super();
|
||||
onWillStart(async () => {
|
||||
var self = this
|
||||
var result;
|
||||
await rpc.query({
|
||||
model: 'access.right',
|
||||
method: 'hide_buttons',
|
||||
}).then(function(data) {
|
||||
result = data;
|
||||
});
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
var group = result[i].module + "." + result[i].group_name
|
||||
if (self.props.resModel == result[i].model) {
|
||||
if (await self.model.user.hasGroup(group)) {
|
||||
if (!self.model.user.isAdmin) {
|
||||
if (result[i].is_create_or_update) {
|
||||
self.props.archInfo.activeActions.create=false
|
||||
self.props.archInfo.activeActions.edit=false
|
||||
}
|
||||
if (result[i].is_delete) {
|
||||
self.props.archInfo.activeActions.delete=false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
50
jikimo_hide_options/static/src/js/list_controller.js
Normal file
50
jikimo_hide_options/static/src/js/list_controller.js
Normal file
@@ -0,0 +1,50 @@
|
||||
/** @odoo-module */
|
||||
/**
|
||||
* This file will used to hide the selected options from the list view
|
||||
*/
|
||||
import { ListController} from '@web/views/list/list_controller';
|
||||
import { patch} from "@web/core/utils/patch";
|
||||
var rpc = require('web.rpc');
|
||||
const {onWillStart} = owl;
|
||||
patch(ListController.prototype, 'jikimo_hide_options/static/src/js/list_controller.js.ListController', {
|
||||
/**
|
||||
* This function will used to hide the selected options from the list view
|
||||
*/
|
||||
setup() {
|
||||
this._super();
|
||||
onWillStart(async () => {
|
||||
var self = this
|
||||
var result;
|
||||
await rpc.query({
|
||||
model: 'access.right',
|
||||
method: 'hide_buttons',
|
||||
}).then(function(data) {
|
||||
result = data;
|
||||
});
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
var group = result[i].module + "." + result[i].group_name
|
||||
if (self.props.resModel == result[i].model) {
|
||||
if (await self.userService.hasGroup(group)) {
|
||||
if (!this.userService.isAdmin) {
|
||||
if (result[i].is_create_or_update) {
|
||||
self.activeActions.create = false;
|
||||
}
|
||||
if (result[i].is_export) {
|
||||
self.isExportEnable = false
|
||||
self.isExportEnable = false
|
||||
}
|
||||
if (result[i].is_delete) {
|
||||
self.activeActions.delete = false;
|
||||
}
|
||||
if (result[i].is_archive) {
|
||||
self.archiveEnabled = false;
|
||||
} else {
|
||||
self.archiveEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user