blob: e39546f2b18745978d3944969f69952a88340c66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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
|