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?
This question has been flagged
3
Replies
490
Views
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.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up| Related Posts | Replies | Views | Activity | |
|---|---|---|---|---|
|
|
0
Mar 15
|
4265 | ||
|
|
1
Mar 26
|
313 | ||
|
|
1
Mar 26
|
289 | ||
|
|
0
Mar 26
|
19 | ||
|
|
0
Mar 26
|
3 |