Skip to content

Commit

Permalink
Merge pull request #121 from INRIM/t_12707
Browse files Browse the repository at this point in the history
[ADD] added anag_avanzamento_rich get rest api
  • Loading branch information
Marcoapu authored Oct 24, 2024
2 parents 42c5952 + 571120c commit 0af4518
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion inrim_controllo_accessi_api/controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
from . import documento
from . import tag
from . import settore_ente
from . import anag_servizi
from . import anag_servizi

This comment has been minimized.

Copy link
@archetipo

archetipo Oct 24, 2024

Member

questo model e' di inrim_controllo_accessi_richieste_accesso e
le api vanno nel controller di quel modulo

from . import anag_avanzamento_rich
12 changes: 12 additions & 0 deletions inrim_controllo_accessi_api/controllers/anag_avanzamento_rich.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import http

from .api_controller_inrim import InrimApiController, BadRequest

class InrimApiAnagAvanzamentoRich(InrimApiController):

@http.route('/api/anag_avanzamento_rich', auth="none", type='http', methods=['GET'],
csrf=False)
def api_get_ca_anag_avanzamento_rich(self, **params):
self.check_token('ca.anag_avanzamento_rich', 'read')
return self.handle_response(
*self.model.rest_get(params), is_list=True)
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ class CaAnagRegistroAccesso(models.Model):
code = fields.Char(compute="_compute_code", store=True)
active = fields.Boolean(default=True)

def rest_boby_hint(self):
return {
"name": "",
"state": ""
}

def rest_get_record(self):
vals = {
'id': self.id,
'name': self.name,
'state': self.f_selection('state', self.state),
'code': self.code
}
return vals

def rest_eval_body(self, body):
body, msg = super().rest_eval_body(
body, [
'name', 'state'
])
return body, msg

@api.depends('name', 'state')
def _compute_code(self):
for record in self:
Expand Down

0 comments on commit 0af4518

Please sign in to comment.