from odoo import fields, models, api, _ from odoo.exceptions import AccessError, UserError, ValidationError class AccountTax(models.Model): _inherit = 'account.tax' @api.model def create(self, vals): group_id = self.env.ref('indoteknik_custom.group_role_it').id users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) if self.env.user.id not in users_in_group.mapped('id'): raise UserError('Hanya IT yang bisa membuat tax') result = super(AccountTax, self).create(vals) return result def write(self, values): group_id = self.env.ref('indoteknik_custom.group_role_it').id users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) if self.env.user.id not in users_in_group.mapped('id'): raise UserError('Hanya IT yang bisa mengedit tax') result = super(AccountTax, self).write(values) return result