From 733b749bb4979e0488b02da48b4116774945d6b5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 24 Sep 2024 15:54:12 +0700 Subject: add validation while create tax --- indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/account_tax.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 indoteknik_custom/models/account_tax.py (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index ad7b1d09..4619147a 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -126,3 +126,4 @@ from . import sale_order_multi_uangmuka_penjualan from . import shipment_group from . import sales_order_reject from . import approval_date_doc +from . import account_tax 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 -- cgit v1.2.3