diff --git a/services/operation_services.py b/services/operation_services.py index e57d2ef667e39af0227591f2a816c973ca030b86..1fe452de26e4b1e399137ca05e685fef83fbabe4 100644 --- a/services/operation_services.py +++ b/services/operation_services.py @@ -212,8 +212,31 @@ class OperationsService(Component): if acc_account_ids else [] ) + + # Récupération de toutes les factures externes + # liées à l'opération spécifiée + domain = [("acc_operation_id", "=", _id)] + + domain += [ + ("type", "=", "facture"), + ] + acc_contract_ids = self.env["acc.contract"].search(domain) + datas["factures_externes"] = ( + 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 toutes les factures liées à l'opération spécifiée + # Récupération de tous les contrats liés à l'opération spécifiée domain = [("acc_operation_id", "=", _id)] domain_pmo = [("acc_operation_id", "=", _id)] role = self._get_role(operation) @@ -707,6 +730,21 @@ class OperationsService(Component): }, }, }, + "factures_externes": { + "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}, + }, + }, + }, "contracts": { "nullable": True, "type": "list",