diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-09-24 15:54:12 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-09-24 15:54:12 +0700 |
| commit | 733b749bb4979e0488b02da48b4116774945d6b5 (patch) | |
| tree | 5a997c89a85c0e2ba6397a76de96ee6c031baaca /indoteknik_custom/models/account_tax.py | |
| parent | 649f3037e4357dab42d1a8d799e5f2a2f1fd2e52 (diff) | |
add validation while create tax
Diffstat (limited to 'indoteknik_custom/models/account_tax.py')
| -rw-r--r-- | indoteknik_custom/models/account_tax.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/indoteknik_custom/models/account_tax.py b/indoteknik_custom/models/account_tax.py new file mode 100644 index 00000000..e698d5ec --- /dev/null +++ b/indoteknik_custom/models/account_tax.py @@ -0,0 +1,14 @@ +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
\ No newline at end of file |
