diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-09-28 10:56:08 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-09-28 10:56:08 +0700 |
| commit | 4e5da6ed950e2129cb50087469c2b56894bafe93 (patch) | |
| tree | 6e1509ddc8bfa78c54004196284851d4e7a6049f /indoteknik_custom/models/account_tax.py | |
| parent | 7909b937bf9484b38f16be1f4be955094e0c25ab (diff) | |
| parent | 0d1bf664d93ff02a42b1962fcf034690b105b8a9 (diff) | |
Merge branch 'production' into iman/switch-account
Diffstat (limited to 'indoteknik_custom/models/account_tax.py')
| -rw-r--r-- | indoteknik_custom/models/account_tax.py | 22 |
1 files changed, 22 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..e39546f2 --- /dev/null +++ b/indoteknik_custom/models/account_tax.py @@ -0,0 +1,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
\ No newline at end of file |
