diff --git a/openapi/controllers/__pycache__/__init__.cpython-36.pyc b/openapi/controllers/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 00000000..0533e8cc Binary files /dev/null and b/openapi/controllers/__pycache__/__init__.cpython-36.pyc differ diff --git a/openapi/controllers/__pycache__/api.cpython-36.pyc b/openapi/controllers/__pycache__/api.cpython-36.pyc new file mode 100644 index 00000000..e6d0a0fb Binary files /dev/null and b/openapi/controllers/__pycache__/api.cpython-36.pyc differ diff --git a/openapi/controllers/__pycache__/apijsonrequest.cpython-36.pyc b/openapi/controllers/__pycache__/apijsonrequest.cpython-36.pyc new file mode 100644 index 00000000..cf061cdd Binary files /dev/null and b/openapi/controllers/__pycache__/apijsonrequest.cpython-36.pyc differ diff --git a/openapi/controllers/__pycache__/main.cpython-36.pyc b/openapi/controllers/__pycache__/main.cpython-36.pyc new file mode 100644 index 00000000..dd826df3 Binary files /dev/null and b/openapi/controllers/__pycache__/main.cpython-36.pyc differ diff --git a/openapi/controllers/__pycache__/pinguin.cpython-36.pyc b/openapi/controllers/__pycache__/pinguin.cpython-36.pyc new file mode 100644 index 00000000..55ac5abc Binary files /dev/null and b/openapi/controllers/__pycache__/pinguin.cpython-36.pyc differ diff --git a/openapi/models/__pycache__/__init__.cpython-36.pyc b/openapi/models/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 00000000..c79457b3 Binary files /dev/null and b/openapi/models/__pycache__/__init__.cpython-36.pyc differ diff --git a/openapi/models/__pycache__/base.cpython-36.pyc b/openapi/models/__pycache__/base.cpython-36.pyc new file mode 100644 index 00000000..f8cf52c6 Binary files /dev/null and b/openapi/models/__pycache__/base.cpython-36.pyc differ diff --git a/openapi/models/__pycache__/ir_exports.cpython-36.pyc b/openapi/models/__pycache__/ir_exports.cpython-36.pyc new file mode 100644 index 00000000..ae4388da Binary files /dev/null and b/openapi/models/__pycache__/ir_exports.cpython-36.pyc differ diff --git a/openapi/models/__pycache__/ir_model.cpython-36.pyc b/openapi/models/__pycache__/ir_model.cpython-36.pyc new file mode 100644 index 00000000..7f862eda Binary files /dev/null and b/openapi/models/__pycache__/ir_model.cpython-36.pyc differ diff --git a/openapi/models/__pycache__/openapi_access.cpython-36.pyc b/openapi/models/__pycache__/openapi_access.cpython-36.pyc new file mode 100644 index 00000000..c6fc9a35 Binary files /dev/null and b/openapi/models/__pycache__/openapi_access.cpython-36.pyc differ diff --git a/openapi/models/__pycache__/openapi_log.cpython-36.pyc b/openapi/models/__pycache__/openapi_log.cpython-36.pyc new file mode 100644 index 00000000..6c400914 Binary files /dev/null and b/openapi/models/__pycache__/openapi_log.cpython-36.pyc differ diff --git a/openapi/models/__pycache__/openapi_namespace.cpython-36.pyc b/openapi/models/__pycache__/openapi_namespace.cpython-36.pyc new file mode 100644 index 00000000..b9612637 Binary files /dev/null and b/openapi/models/__pycache__/openapi_namespace.cpython-36.pyc differ diff --git a/openapi/models/__pycache__/res_users.cpython-36.pyc b/openapi/models/__pycache__/res_users.cpython-36.pyc new file mode 100644 index 00000000..0721f8b5 Binary files /dev/null and b/openapi/models/__pycache__/res_users.cpython-36.pyc differ diff --git a/openapi/models/base.py b/openapi/models/base.py index bfb3fba5..1b6ff7c0 100644 --- a/openapi/models/base.py +++ b/openapi/models/base.py @@ -6,6 +6,8 @@ class Base(models.AbstractModel): _inherit = "base" + + @api.model def search_or_create(self, vals, active_test=True): domain = [(k, "=", v) for k, v in vals.items()] @@ -15,3 +17,4 @@ def search_or_create(self, vals, active_test=True): is_new = True records = self.create(vals) return (is_new, records.ids) + diff --git a/openapi/models/ir_model.py b/openapi/models/ir_model.py index b68528a6..74fe68e1 100644 --- a/openapi/models/ir_model.py +++ b/openapi/models/ir_model.py @@ -6,6 +6,7 @@ class IrModel(models.Model): _inherit = "ir.model" + api_access_ids = fields.One2many("openapi.access", "model_id", "Access via API") api_accesses_count = fields.Integer( compute="_compute_related_accesses_count", @@ -13,6 +14,7 @@ class IrModel(models.Model): store=False, ) + @api.multi def _compute_related_accesses_count(self): for record in self: diff --git a/openapi/models/openapi_namespace.py b/openapi/models/openapi_namespace.py index 3842190f..e3481b69 100644 --- a/openapi/models/openapi_namespace.py +++ b/openapi/models/openapi_namespace.py @@ -17,6 +17,8 @@ class Namespace(models.Model): _name = "openapi.namespace" _description = "Integration" + + active = fields.Boolean("Active", default=True) name = fields.Char( "Name", @@ -256,6 +258,8 @@ def _compute_last_used(self): .create_date ) + + def _compute_log_count(self): self._cr.execute( "SELECT COUNT(*) FROM openapi_log WHERE namespace_id=(%s);", [str(self.id)] diff --git a/openapi/models/res_users.py b/openapi/models/res_users.py index 1aeebf12..279ac07f 100644 --- a/openapi/models/res_users.py +++ b/openapi/models/res_users.py @@ -2,14 +2,20 @@ # Copyright 2018 Rafis Bikbov # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). import uuid - +import wdb from odoo import api, fields, models + class ResUsers(models.Model): _inherit = "res.users" namespace_ids = fields.Many2many("openapi.namespace", string="Allowed Integrations") + is_same_user = fields.Boolean( + compute='is_the_same_user', + store=False, + string='Same User' + ) openapi_token = fields.Char( "OpenAPI Token", default=lambda self: self._get_unique_openapi_token(), @@ -29,6 +35,15 @@ def _get_unique_openapi_token(self): openapi_token = str(uuid.uuid4()) return openapi_token + def is_the_same_user(self): + for record in self: + record.is_same_user = self.id == self.env.uid + @api.model def reset_all_openapi_tokens(self): self.search([]).reset_openapi_token() + + + + + diff --git a/openapi/security/ir.model.access.csv b/openapi/security/ir.model.access.csv index b1cb50a9..39b9554d 100644 --- a/openapi/security/ir.model.access.csv +++ b/openapi/security/ir.model.access.csv @@ -7,3 +7,4 @@ manager_access_openapi_log,access_openapi_log,model_openapi_log,openapi.group_ma manager_access_openapi_namespace,access_openapi_namespace,model_openapi_namespace,openapi.group_manager,1,1,1,1 manager_access_openapi_access,access_openapi_access,model_openapi_access,openapi.group_manager,1,1,1,1 manager_access_openapi_access_create_context,access_openapi_access_create_context,model_openapi_access_create_context,openapi.group_manager,1,1,1,1 +manager_access_openapi_user_token,access_openapi_user_token,base.view_users_simple_form,openapi.group_manager,0,0,0,0 \ No newline at end of file diff --git a/openapi/views/openapi_view.xml b/openapi/views/openapi_view.xml index 3895d42f..2deb4f5c 100644 --- a/openapi/views/openapi_view.xml +++ b/openapi/views/openapi_view.xml @@ -1,5 +1,17 @@ + + ir.exports.form ir.exports @@ -217,6 +229,11 @@ +
+ + + + @@ -224,6 +241,18 @@
+ + openapi.namespace.managerview + openapi.namespace + + + + + + + + + openapi.namespace.tree openapi.namespace