mirror of
https://github.com/Ladebeze66/llm_ticket3.git
synced 2025-12-15 21:16:52 +01:00
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
# extract_tracking_values_by_id.py
|
|
|
|
import json
|
|
import os
|
|
from odoo.auth_manager import AuthManager
|
|
|
|
CONFIG_FILE = "config.json"
|
|
|
|
def load_config(path=CONFIG_FILE):
|
|
with open(path, "r") as f:
|
|
return json.load(f)
|
|
|
|
def fetch_tracking_values(ids, config_file=CONFIG_FILE):
|
|
config = load_config(config_file)
|
|
odoo_cfg = config["odoo"]
|
|
|
|
auth = AuthManager(
|
|
url=odoo_cfg["url"],
|
|
db=odoo_cfg["db"],
|
|
username=odoo_cfg["username"],
|
|
api_key=odoo_cfg["api_key"]
|
|
)
|
|
if not auth.login():
|
|
print("❌ Échec de l'authentification.")
|
|
return
|
|
|
|
result = auth.read(
|
|
model="mail.tracking.value",
|
|
ids=ids,
|
|
fields=["field", "field_desc", "old_value_char", "new_value_char"]
|
|
)
|
|
|
|
# Sauvegarde JSON
|
|
out_path = "tracking_value_result.json"
|
|
with open(out_path, "w", encoding="utf-8") as f:
|
|
json.dump(result, f, indent=2, ensure_ascii=False)
|
|
|
|
print(f"✅ Résultat enregistré dans {out_path}")
|
|
for entry in result:
|
|
print(f"- Champ : {entry['field_desc']}")
|
|
print(f" Ancienne valeur : {entry['old_value_char']}")
|
|
print(f" Nouvelle valeur : {entry['new_value_char']}")
|
|
print()
|
|
|
|
if __name__ == "__main__":
|
|
import argparse
|
|
parser = argparse.ArgumentParser(description="Lire les valeurs de suivi (mail.tracking.value)")
|
|
parser.add_argument("ids", nargs="+", type=int, help="IDs à interroger (ex: 179095)")
|
|
parser.add_argument("--config", "-c", default=CONFIG_FILE, help="Chemin vers le fichier config")
|
|
args = parser.parse_args()
|
|
|
|
fetch_tracking_values(args.ids, args.config)
|