mirror of
https://github.com/Ladebeze66/llm_ticket3.git
synced 2025-12-16 14:57:47 +01:00
27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
from typing import Dict, Any, List
|
|
from .auth_manager import AuthManager
|
|
|
|
class TicketManager:
|
|
def __init__(self, auth: AuthManager):
|
|
self.auth = auth
|
|
self.model_name = "project.task"
|
|
|
|
def get_ticket(self, ticket_id: int) -> Dict[str, Any]:
|
|
params = {
|
|
"model": self.model_name,
|
|
"method": "read",
|
|
"args": [[ticket_id]],
|
|
"kwargs": {"fields": ["id", "name", "description", "stage_id", "user_id", "create_date"]}
|
|
}
|
|
return self.auth._rpc_call("/web/dataset/call_kw", params)
|
|
|
|
def get_ticket_by_code(self, ticket_code: str) -> Dict[str, Any]:
|
|
params = {
|
|
"model": self.model_name,
|
|
"method": "search_read",
|
|
"args": [[["code", "=", ticket_code]], ["id", "name", "description", "stage_id", "user_id", "create_date"]],
|
|
"kwargs": {"limit": 1}
|
|
}
|
|
result = self.auth._rpc_call("/web/dataset/call_kw", params)
|
|
return result[0] if isinstance(result, list) and result else {}
|