26 lines
798 B
Python
26 lines
798 B
Python
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 []
|
|
|