Initial commit from monorepo
This commit is contained in:
25
exchange/services.py
Normal file
25
exchange/services.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import requests as http_requests
|
||||
from django.conf import settings
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class OdooService:
|
||||
def __init__(self):
|
||||
self.base_url = f"http://{settings.ODOO_INTERNAL_URL}"
|
||||
|
||||
def get_products(self):
|
||||
"""Получить список всех товаров из Odoo"""
|
||||
try:
|
||||
url = f"{self.base_url}/fastapi/products/products"
|
||||
response = http_requests.get(url, timeout=10)
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
else:
|
||||
logger.error(f"Error fetching products: {response.status_code}")
|
||||
return []
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching products from Odoo: {e}")
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user