From e9c795323f823059f284326e578af548fe89a88e Mon Sep 17 00:00:00 2001 From: Juliana <juliana@le-filament.com> Date: Mon, 12 Sep 2022 18:11:06 +0200 Subject: [PATCH] [ADD]ADD new menu other docs app --- services/operation_services.py | 57 +++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/services/operation_services.py b/services/operation_services.py index 5ccd5c4..9194426 100644 --- a/services/operation_services.py +++ b/services/operation_services.py @@ -235,6 +235,40 @@ class OperationsService(Component): if acc_contract_ids else [] ) + elif type == "other": + # Récupération de tous les contrats liés à l'opération spécifiée + domain = [("acc_operation_id", "=", _id)] + role = self._get_role(operation) + # if role.get("isConsumer") or role.get("isProductor"): + # domain += [ + # ("type", "!=", "convention"), + # ("type", "!=", "all"), + # ("type", "!=", False), + # ] + # if role.get("isPmo"): + # domain_pmo += [("type", "!=", False)] + # acc_contract_ids = self.env["acc.contract"].sudo().search(domain_pmo) + # else: + acc_contract_ids = self.env["acc.contract"].sudo().search([ + ("acc_operation_id", "=", _id), ("type", "=", "all"), + ]) + # acc_contract_ids = self.env["acc.contract"].search(domain) + # acc_contract_ids += acc_contract_all + + datas["other"] = ( + acc_contract_ids.mapped( + lambda n: { + "id": n.id, + "name": n.name, + "start_date": n.start_date, + "end_date": n.end_date, + "type": n.type, + "url": base_url + n.get_portal_url(), + } + ) + if acc_contract_ids + else [] + ) else: # Récupération de tous les contrats liés à l'opération spécifiée domain = [("acc_operation_id", "=", _id)] @@ -250,11 +284,11 @@ class OperationsService(Component): domain_pmo += [("type", "!=", False)] acc_contract_ids = self.env["acc.contract"].sudo().search(domain_pmo) else: - acc_contract_all = self.env["acc.contract"].sudo().search([ - ("acc_operation_id", "=", _id), ("type", "=", "all"), - ]) + # acc_contract_all = self.env["acc.contract"].sudo().search([ + # ("acc_operation_id", "=", _id), ("type", "=", "all"), + # ]) acc_contract_ids = self.env["acc.contract"].search(domain) - acc_contract_ids += acc_contract_all + # acc_contract_ids += acc_contract_all datas["contracts"] = ( acc_contract_ids.mapped( @@ -764,6 +798,21 @@ class OperationsService(Component): }, }, }, + "other": { + "nullable": True, + "type": "list", + "schema": { + "type": "dict", + "schema": { + "id": {"type": "integer"}, + "name": {"type": "string"}, + "type": {"type": "string", "nullable": True}, + "url": {"type": "string", "nullable": True}, + "seller": {"type": "string", "nullable": True}, + "buyer": {"type": "string", "nullable": True}, + }, + }, + }, } def _validator_get_pmo(self): -- GitLab