From 15472183692c18a40f90b8817831f227bf36eeaa Mon Sep 17 00:00:00 2001 From: Juliana <juliana@le-filament.com> Date: Thu, 11 Aug 2022 16:18:03 +0200 Subject: [PATCH] [ADD]Add page contact PRM --- services/operation_services.py | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/services/operation_services.py b/services/operation_services.py index b3b7665..e57d2ef 100644 --- a/services/operation_services.py +++ b/services/operation_services.py @@ -540,6 +540,32 @@ class OperationsService(Component): } return datas + @restapi.method( + [(["/<int:id>/contact"], "GET")], + output_param=restapi.CerberusValidator("_validator_return_get_contact"), + cors="*", + crsf=False, + ) + def get_contact(self, _id): + """ + Retourne les données de l'opération + dans laquelle l'utilisateur ou sa société sont engagés + """ + operation = self.env["acc.operation"].browse(_id) + + role = self._get_role(operation) + if not role.get("isIn"): + return AccessError() + + datas = { + "role": role, + "id": operation.id, + "name": operation.name, + "email": operation.pmo_id.email + } + + return datas + # ------------------------------------------------------ # Validators # ------------------------------------------------------ @@ -625,6 +651,25 @@ class OperationsService(Component): }, } + def _validator_return_get_contact(self): + return { + "role": { + "type": "dict", + "schema": { + "id": {"type": "integer"}, + "name": {"type": "string"}, + "description": {"type": "string"}, + "isIn": {"type": "boolean"}, + "isPmo": {"type": "boolean"}, + "isConsumer": {"type": "boolean"}, + "isProductor": {"type": "boolean"}, + }, + }, + "id": {"type": "integer"}, + "name": {"type": "string"}, + "email": {"type": "string"}, + } + def _validator_get_doc(self): return { "id": {"type": "integer"}, -- GitLab