diff --git a/services/operation_services.py b/services/operation_services.py index 80eded5aa167d4ab858aec0e4e82ce6601c94fb7..5470d55a91e192864437bce48c8b53ec59dd8539 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