I was trying to hide some buttons in actions, but I couldn't find the duplicate and delete buttons in the Odoo 18 repository. Does anyone know how I could hide these functions per user?
La domanda è stata contrassegnata
3
Risposte
1260
Visualizzazioni
Hello,
You can hide like this
/** @odoo-module **/
You can hide like this
/** @odoo-module **/
import {patch} from "@web/core/utils/patch";
import {ActionMenus} from "@web/search/action_menus/action_menus";
import {useService} from "@web/core/utils/hooks";
import { user } from "@web/core/user";
patch(ActionMenus.prototype, {
setup(...args) {
super.setup(...args);
this.user = user
},
async getActionItems(props) {
let result = await super.getActionItems(...arguments)
const isAdmin = this.user.isAdmin
const user_group = await this.user.hasGroup("group_id");[as per your requirement]
const user_group = await this.user.hasGroup("group_id");[as per your requirement]
if (!isAdmin && user_group) {
result = result.filter(item => item.key !== 'delete' && item.key !== 'duplicate');
}
return result
}
});
Hope this helps.
thanks for the help, it worked!!
Hi,
Please go through the following module,
* https://apps.odoo.com/apps/modules/17.0/model_access_rights
* https://odoo-community.org/shop/hide-duplicate-button-3413#attr=5758
Hope it helps
I migrated the module to v18 and it worked, it wasn't exactly what I was looking for, but thanks anyway!!
You can disable a user's ability to edit or delete records by removing the Edit and Unlink permissions for the corresponding user group in the Model Access (ir.model.access) settings.
Once these permissions are removed, the corresponding Edit and Delete menu options will automatically be hidden for that user.
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!
Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!
Registrati| Post correlati | Risposte | Visualizzazioni | Attività | |
|---|---|---|---|---|
|
|
0
mar 15
|
4768 | ||
|
|
2
mar 26
|
1156 | ||
|
|
0
giu 26
|
1 | ||
|
|
0
giu 26
|
282 | ||
|
|
0
giu 26
|
1 |