robin.keunen
5 years ago
6 changed files with 93 additions and 12 deletions
-
16easy_my_coop_api/README.rst
-
1easy_my_coop_api/__init__.py
-
1easy_my_coop_api/models/__init__.py
-
34easy_my_coop_api/models/auth_api_key.py
-
12easy_my_coop_api/readme/USAGE.rst
-
41easy_my_coop_api/static/description/index.html
@ -1,2 +1,3 @@ |
|||
from . import controllers |
|||
from . import models |
|||
from . import services |
@ -0,0 +1 @@ |
|||
from . import auth_api_key |
@ -0,0 +1,34 @@ |
|||
# Copyright 2020 Coop IT Easy SCRL fs |
|||
# Robin Keunen <robin@coopiteasy.be> |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
|
|||
import uuid |
|||
|
|||
from odoo import api, fields, models |
|||
|
|||
|
|||
class AuthApiKey(models.Model): |
|||
_inherit = "auth.api.key" |
|||
|
|||
def _default_key(self): |
|||
return uuid.uuid4() |
|||
|
|||
# overloaded fields |
|||
# required is set to false to allow for a computed field, |
|||
# it will always be set. |
|||
name = fields.Char(required=False, compute="_compute_name", store=True) |
|||
key = fields.Char(default=_default_key) |
|||
|
|||
@api.multi |
|||
@api.depends("user_id") |
|||
def _compute_name(self): |
|||
for key in self: |
|||
if key.user_id: |
|||
now = fields.Datetime.now() |
|||
|
|||
key.name = "{login}-{now}".format( |
|||
now=fields.Datetime.to_string(now), |
|||
login=key.user_id.login, |
|||
) |
|||
else: |
|||
key.name = "no-user" |
@ -0,0 +1,12 @@ |
|||
To give access to the API to a structure, go to |
|||
|
|||
- Settings > Technical (debug mode) > Auth API Key |
|||
- click create and select a user, save. |
|||
- communicate the API-KEY to the structure. |
|||
|
|||
It is recommended to create a technical user for the structure belonging to the group "Easy My Coop User". |
|||
For example, for the structure Coop IT Easy, create partner with |
|||
|
|||
- name = coopiteasy-api-user |
|||
- Application Accesses = Cooperative Management / User |
|||
- Platform Structure = Coop IT Easy |
Write
Preview
Loading…
Cancel
Save
Reference in new issue