From b19232098541b8b2cd48616743ab3d726ce90f46 Mon Sep 17 00:00:00 2001
From: Juliana <juliana@le-filament.com>
Date: Wed, 9 Aug 2023 15:04:53 +0200
Subject: [PATCH] [ADD]Add domain restrict PMO doc

---
 services/operation_services.py | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/services/operation_services.py b/services/operation_services.py
index 80eded5..5470d55 100644
--- a/services/operation_services.py
+++ b/services/operation_services.py
@@ -212,6 +212,8 @@ class OperationsService(Component):
 
         # Récupération de tous les contrats liés à l'opération spécifiée
         domain_c = [("acc_operation_id", "=", _id)]
+        domain_pmo = [("acc_operation_id", "=", _id)]
+
         role = self._get_role(operation)
         if role.get("isConsumer") or role.get("isProductor"):
             domain_c += [
@@ -220,14 +222,18 @@ class OperationsService(Component):
                 ("type", "=", "vente_achat"),
             ]
 
-        acc_contract_all = (
-            self.env["acc.contract"]
-            .sudo()
-            .search([
-                ("acc_operation_id", "=", _id),
-                ("type", "=", "all"),
-                ])
-            )
+        if role.get("isPmo"):
+            domain_pmo += [("type", "!=", False)]
+            acc_contract_ids = self.env["acc.contract"].search(domain_pmo)
+        else:
+            acc_contract_all = (
+                self.env["acc.contract"]
+                .sudo()
+                .search([
+                    ("acc_operation_id", "=", _id),
+                    ("type", "=", "all"),
+                    ])
+                )
         acc_contract_ids = self.env["acc.contract"].search(domain_c)
         acc_contract_ids += acc_contract_all
 
-- 
GitLab