mirror of
https://github.com/Ladebeze66/odoo_toolkit.git
synced 2025-12-13 12:36:52 +01:00
correctifs2
This commit is contained in:
parent
6d21fd5b61
commit
ee16584442
@ -4,33 +4,6 @@ from utils import get_user_choice
|
|||||||
# Initialisation de l'objet
|
# Initialisation de l'objet
|
||||||
ticket_manager = TicketManager()
|
ticket_manager = TicketManager()
|
||||||
|
|
||||||
def handle_list_models():
|
|
||||||
"""Gère l'affichage de la liste des modèles"""
|
|
||||||
ticket_manager.list_models()
|
|
||||||
|
|
||||||
|
|
||||||
def handle_list_model_fields():
|
|
||||||
"""Gère l'affichage des champs d'un modèle"""
|
|
||||||
model_name = input("\nEntrez le nom du modèle: ")
|
|
||||||
if not model_name:
|
|
||||||
print("Aucun nom de modèle fourni.")
|
|
||||||
return
|
|
||||||
ticket_manager.list_model_fields(model_name)
|
|
||||||
|
|
||||||
|
|
||||||
def handle_export_model_fields_to_json():
|
|
||||||
"""Gère l'exportation des informations des champs d'un modèle en JSON"""
|
|
||||||
model_name = input("\nEntrez le nom du modèle: ")
|
|
||||||
if not model_name:
|
|
||||||
print("Aucun nom de modèle fourni.")
|
|
||||||
return
|
|
||||||
filename = input("Entrez le nom du fichier pour l'exportation: ")
|
|
||||||
if not filename:
|
|
||||||
print("Aucun nom de fichier fourni.")
|
|
||||||
return
|
|
||||||
ticket_manager.export_model_fields_to_json(model_name, filename)
|
|
||||||
|
|
||||||
|
|
||||||
def handle_project_tickets_by_stage():
|
def handle_project_tickets_by_stage():
|
||||||
"""Gère l'exportation des tickets d'un projet par étape"""
|
"""Gère l'exportation des tickets d'un projet par étape"""
|
||||||
# Récupérer la liste des projets disponibles
|
# Récupérer la liste des projets disponibles
|
||||||
|
|||||||
@ -1,18 +1,12 @@
|
|||||||
from menu_handlers import (
|
from menu_handlers import (
|
||||||
handle_list_models,
|
|
||||||
handle_list_model_fields,
|
|
||||||
handle_export_model_fields_to_json,
|
|
||||||
handle_project_tickets_by_stage
|
handle_project_tickets_by_stage
|
||||||
)
|
)
|
||||||
|
|
||||||
def display_main_menu():
|
def display_main_menu():
|
||||||
"""Affiche le menu principal de l'application"""
|
"""Affiche le menu principal de l'application"""
|
||||||
print("\n==== GESTIONNAIRE DE TICKETS ODOO ====")
|
print("\n==== GESTIONNAIRE DE TICKETS ODOO ====")
|
||||||
print("1. Afficher la liste des modèles")
|
print("1. Exporter les tickets d'un project_id par étape")
|
||||||
print("2. Afficher les champs d'un modèle")
|
print("2. Quitter")
|
||||||
print("3. Exporter les informations des champs d'un modèle en JSON")
|
|
||||||
print("4. Exporter les tickets d'un project_id par étape")
|
|
||||||
print("5. Quitter")
|
|
||||||
return input("\nChoisissez une option (1-5): ")
|
return input("\nChoisissez une option (1-5): ")
|
||||||
|
|
||||||
|
|
||||||
@ -20,16 +14,9 @@ def run_menu():
|
|||||||
"""Exécute la boucle du menu principal"""
|
"""Exécute la boucle du menu principal"""
|
||||||
while True:
|
while True:
|
||||||
choice = display_main_menu()
|
choice = display_main_menu()
|
||||||
|
|
||||||
if choice == '1':
|
if choice == '1':
|
||||||
handle_list_models()
|
|
||||||
elif choice == '2':
|
|
||||||
handle_list_model_fields()
|
|
||||||
elif choice == '3':
|
|
||||||
handle_export_model_fields_to_json()
|
|
||||||
elif choice == '4':
|
|
||||||
handle_project_tickets_by_stage()
|
handle_project_tickets_by_stage()
|
||||||
elif choice == '5':
|
elif choice == '2':
|
||||||
print("Au revoir!")
|
print("Au revoir!")
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|||||||
66
old_functions.py
Normal file
66
old_functions.py
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
def handle_list_models():
|
||||||
|
"""Gère l'affichage de la liste des modèles"""
|
||||||
|
ticket_manager.list_models()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def handle_list_model_fields():
|
||||||
|
"""Gère l'affichage des champs d'un modèle"""
|
||||||
|
model_name = input("\nEntrez le nom du modèle: ")
|
||||||
|
if not model_name:
|
||||||
|
print("Aucun nom de modèle fourni.")
|
||||||
|
return
|
||||||
|
ticket_manager.list_model_fields(model_name)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_export_model_fields_to_json():
|
||||||
|
"""Gère l'exportation des informations des champs d'un modèle en JSON"""
|
||||||
|
model_name = input("\nEntrez le nom du modèle: ")
|
||||||
|
if not model_name:
|
||||||
|
print("Aucun nom de modèle fourni.")
|
||||||
|
return
|
||||||
|
filename = input("Entrez le nom du fichier pour l'exportation: ")
|
||||||
|
if not filename:
|
||||||
|
print("Aucun nom de fichier fourni.")
|
||||||
|
return
|
||||||
|
ticket_manager.export_model_fields_to_json(model_name, filename)
|
||||||
|
|
||||||
|
///partie ticket_manager.py
|
||||||
|
def list_models(self):
|
||||||
|
"""Affiche la liste des modèles disponibles dans Odoo"""
|
||||||
|
models = self._safe_execute('ir.model', 'search_read', [], ['model', 'name'])
|
||||||
|
if not models:
|
||||||
|
print_error("Aucun modèle disponible.")
|
||||||
|
return []
|
||||||
|
|
||||||
|
print("\nListe des modèles disponibles:")
|
||||||
|
for model in models:
|
||||||
|
print(f"Modèle: {model['name']} (ID: {model['model']})")
|
||||||
|
return models
|
||||||
|
|
||||||
|
def list_model_fields(self, model_name):
|
||||||
|
"""Affiche les champs d'un modèle donné"""
|
||||||
|
fields_info = self._safe_execute(model_name, 'fields_get')
|
||||||
|
if not fields_info:
|
||||||
|
print_error(f"Aucun champ trouvé pour le modèle {model_name}.")
|
||||||
|
return []
|
||||||
|
|
||||||
|
print(f"\nChamps du modèle {model_name}:")
|
||||||
|
for field_name, field_data in fields_info.items():
|
||||||
|
print(f"Champ: {field_name} - Type: {field_data['type']}")
|
||||||
|
return fields_info
|
||||||
|
|
||||||
|
def export_model_fields_to_json(self, model_name, filename):
|
||||||
|
"""Exporte les champs d'un modèle dans un fichier JSON"""
|
||||||
|
fields_info = self._safe_execute(model_name, 'fields_get')
|
||||||
|
if not fields_info:
|
||||||
|
print_error(f"Aucun champ trouvé pour le modèle {model_name}.")
|
||||||
|
return
|
||||||
|
|
||||||
|
data = {field_name: field_data['type'] for field_name, field_data in fields_info.items()}
|
||||||
|
filepath = os.path.join(EXPORT_DIR, filename)
|
||||||
|
|
||||||
|
if save_json(filepath, data):
|
||||||
|
print(f"Champs du modèle {model_name} exportés dans {filepath}")
|
||||||
|
else:
|
||||||
|
print_error(f"Erreur lors de l'exportation des champs du modèle {model_name} dans {filepath}")
|
||||||
@ -60,45 +60,6 @@ class TicketManager:
|
|||||||
# Nettoyer et filtrer les données du ticket
|
# Nettoyer et filtrer les données du ticket
|
||||||
return filter_ticket_data(ticket_data[0]) # Utilisation de data_filter.py
|
return filter_ticket_data(ticket_data[0]) # Utilisation de data_filter.py
|
||||||
|
|
||||||
def list_models(self):
|
|
||||||
"""Affiche la liste des modèles disponibles dans Odoo"""
|
|
||||||
models = self._safe_execute('ir.model', 'search_read', [], ['model', 'name'])
|
|
||||||
if not models:
|
|
||||||
print_error("Aucun modèle disponible.")
|
|
||||||
return []
|
|
||||||
|
|
||||||
print("\nListe des modèles disponibles:")
|
|
||||||
for model in models:
|
|
||||||
print(f"Modèle: {model['name']} (ID: {model['model']})")
|
|
||||||
return models
|
|
||||||
|
|
||||||
def list_model_fields(self, model_name):
|
|
||||||
"""Affiche les champs d'un modèle donné"""
|
|
||||||
fields_info = self._safe_execute(model_name, 'fields_get')
|
|
||||||
if not fields_info:
|
|
||||||
print_error(f"Aucun champ trouvé pour le modèle {model_name}.")
|
|
||||||
return []
|
|
||||||
|
|
||||||
print(f"\nChamps du modèle {model_name}:")
|
|
||||||
for field_name, field_data in fields_info.items():
|
|
||||||
print(f"Champ: {field_name} - Type: {field_data['type']}")
|
|
||||||
return fields_info
|
|
||||||
|
|
||||||
def export_model_fields_to_json(self, model_name, filename):
|
|
||||||
"""Exporte les champs d'un modèle dans un fichier JSON"""
|
|
||||||
fields_info = self._safe_execute(model_name, 'fields_get')
|
|
||||||
if not fields_info:
|
|
||||||
print_error(f"Aucun champ trouvé pour le modèle {model_name}.")
|
|
||||||
return
|
|
||||||
|
|
||||||
data = {field_name: field_data['type'] for field_name, field_data in fields_info.items()}
|
|
||||||
filepath = os.path.join(EXPORT_DIR, filename)
|
|
||||||
|
|
||||||
if save_json(filepath, data):
|
|
||||||
print(f"Champs du modèle {model_name} exportés dans {filepath}")
|
|
||||||
else:
|
|
||||||
print_error(f"Erreur lors de l'exportation des champs du modèle {model_name} dans {filepath}")
|
|
||||||
|
|
||||||
def export_tickets_by_project_and_stage(self, project_id, selected_stage_ids=None):
|
def export_tickets_by_project_and_stage(self, project_id, selected_stage_ids=None):
|
||||||
""" Exporte les tickets d'un projet classés par étape """
|
""" Exporte les tickets d'un projet classés par étape """
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user