summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/res_users.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-02-28 14:07:47 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-02-28 14:07:47 +0700
commit00b6739e4f4228c1cc66de0ef63312bc633ae21f (patch)
tree85f8fc83d4030878893599abb2a949e5d478e3e7 /indoteknik_custom/models/res_users.py
parent0738a192409687790c16c757f85fe440cb1f377d (diff)
parent46a7cc5601ceab2a7a6cdf4d74e0fa26ce13ab8a (diff)
Merge branch 'production' into purchasing-job
Diffstat (limited to 'indoteknik_custom/models/res_users.py')
-rwxr-xr-xindoteknik_custom/models/res_users.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py
index 09321fc6..33f64ce3 100755
--- a/indoteknik_custom/models/res_users.py
+++ b/indoteknik_custom/models/res_users.py
@@ -39,3 +39,20 @@ class ResUsers(models.Model):
if not vouchers: return None
return ', '.join(x.code for x in vouchers)
return None
+
+ def check_access(self, model, mode):
+ assert mode in ('read', 'write', 'create', 'unlink', 'import', 'export'), 'Invalid access mode'
+
+ self._cr.execute("""
+ SELECT MAX(CASE WHEN perm_{mode} THEN 1 ELSE 0 END)
+ FROM ir_model_access a
+ JOIN ir_model m ON (m.id = a.model_id)
+ JOIN res_groups_users_rel gu ON (gu.gid = a.group_id)
+ WHERE m.model = %s
+ AND gu.uid = %s
+ AND a.active IS TRUE
+ """.format(mode=mode), (model, self._uid,))
+ r = self._cr.fetchone()[0]
+
+ return bool(r)
+