From 4eaeaf334cc3f80abb7d45738be53c7f0dea6c4c Mon Sep 17 00:00:00 2001 From: Juliana <juliana@le-filament.com> Date: Tue, 20 Sep 2022 15:10:51 +0200 Subject: [PATCH] [UPD]Display/hide title depending numer contracts --- services/operation_services.py | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/services/operation_services.py b/services/operation_services.py index f3f1e6e..e84ccf9 100644 --- a/services/operation_services.py +++ b/services/operation_services.py @@ -217,6 +217,7 @@ class OperationsService(Component): domain_c += [ ("type", "!=", "convention"), ("type", "!=", "all"), + ("type", "!=", "pmo"), ("type", "!=", False), ] if role.get("isPmo"): @@ -228,6 +229,11 @@ class OperationsService(Component): ]) acc_contract_ids = self.env["acc.contract"].search(domain_c) acc_contract_ids += acc_contract_all + + acc_contract_pmo = self.env["acc.contract"].search([ + ("acc_operation_id", "=", _id), ("type", "=", "pmo"), + ]) + acc_contract_ids += acc_contract_pmo contract_exist = False if acc_contract_ids: contract_exist = True @@ -279,6 +285,20 @@ class OperationsService(Component): if acc_contract_ids else [] ) + datas["contracts_pmo"] = ( + acc_contract_pmo.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_pmo + else [] + ) datas["contract_exist"] = contract_exist datas["invoice_exist"] = invoice_exist return datas @@ -777,6 +797,21 @@ class OperationsService(Component): }, }, }, + "contracts_pmo": { + "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