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?
Pertanyaan ini telah diberikan tanda
3
Replies
492
Tampilan
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.
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
Daftar| Post Terkait | Replies | Tampilan | Aktivitas | |
|---|---|---|---|---|
|
|
0
Mar 15
|
4266 | ||
|
|
1
Mar 26
|
313 | ||
|
|
1
Mar 26
|
293 | ||
|
|
0
Mar 26
|
19 | ||
|
|
0
Mar 26
|
3 |