summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-09-24 15:54:12 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-09-24 15:54:12 +0700
commit733b749bb4979e0488b02da48b4116774945d6b5 (patch)
tree5a997c89a85c0e2ba6397a76de96ee6c031baaca /indoteknik_custom/models
parent649f3037e4357dab42d1a8d799e5f2a2f1fd2e52 (diff)
add validation while create tax
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/account_tax.py14
2 files changed, 15 insertions, 0 deletions
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