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?
Cette question a été signalée
3
Réponses
493
Vues
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.
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrire| Publications associées | Réponses | Vues | Activité | |
|---|---|---|---|---|
|
|
0
mars 15
|
4267 | ||
|
|
1
mars 26
|
314 | ||
|
|
1
mars 26
|
296 | ||
|
|
0
mars 26
|
19 | ||
|
|
0
mars 26
|
3 |