From 571120c8e4f9d0c564250b33b410552bdfef9eb2 Mon Sep 17 00:00:00 2001 From: Marcoapu Date: Thu, 24 Oct 2024 10:50:57 +0200 Subject: [PATCH] [ADD] added anag_avanzamento_rich get rest api --- .../controllers/__init__.py | 3 ++- .../controllers/anag_avanzamento_rich.py | 12 ++++++++++ .../models/ca_anag_avanzamento_rich.py | 22 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 inrim_controllo_accessi_api/controllers/anag_avanzamento_rich.py diff --git a/inrim_controllo_accessi_api/controllers/__init__.py b/inrim_controllo_accessi_api/controllers/__init__.py index 08db174..031f802 100644 --- a/inrim_controllo_accessi_api/controllers/__init__.py +++ b/inrim_controllo_accessi_api/controllers/__init__.py @@ -8,4 +8,5 @@ from . import documento from . import tag from . import settore_ente -from . import anag_servizi \ No newline at end of file +from . import anag_servizi +from . import anag_avanzamento_rich \ No newline at end of file diff --git a/inrim_controllo_accessi_api/controllers/anag_avanzamento_rich.py b/inrim_controllo_accessi_api/controllers/anag_avanzamento_rich.py new file mode 100644 index 0000000..c198ea8 --- /dev/null +++ b/inrim_controllo_accessi_api/controllers/anag_avanzamento_rich.py @@ -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) \ No newline at end of file diff --git a/inrim_controllo_accessi_richieste_accesso/models/ca_anag_avanzamento_rich.py b/inrim_controllo_accessi_richieste_accesso/models/ca_anag_avanzamento_rich.py index 7e161a8..452ea18 100644 --- a/inrim_controllo_accessi_richieste_accesso/models/ca_anag_avanzamento_rich.py +++ b/inrim_controllo_accessi_richieste_accesso/models/ca_anag_avanzamento_rich.py @@ -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: