82 lines
2.1 KiB
Python
82 lines
2.1 KiB
Python
from seller.catalog_tools import CatalogTrytonTools
|
|
import json
|
|
|
|
# result = json.dumps(response, indent=4)
|
|
|
|
url = "http://192.168.0.25:8000"
|
|
key = "9a9ffc430146447d81e6698240199a4be2b0e774cb18474999d0f60e33b5b1eb1cfff9d9141346a98844879b5a9e787489c891ddc8fb45cc903b7244cab64fb1"
|
|
db = "tryton"
|
|
application_name = "sale_don_confiao"
|
|
|
|
|
|
catalog = CatalogTrytonTools(url, application_name, key, db)
|
|
|
|
# Lista de los productos
|
|
print("=== Productos ===")
|
|
|
|
response = catalog.list_products()
|
|
|
|
products: str = ""
|
|
|
|
for product in response:
|
|
id = product["id"]
|
|
name = product["name"]
|
|
id_unit_measurement = product["default_uom."]["id"]
|
|
products += f"- id: {id} - Nombre: {name} - ID Unidad de Medida: {id_unit_measurement}\n"
|
|
|
|
print(products)
|
|
|
|
# Precio del los productos
|
|
print("=== Precios de los productos ===")
|
|
|
|
response = catalog.search_products("Arroz")
|
|
precios: str = ""
|
|
|
|
for product in response:
|
|
id = product["id"]
|
|
name = product["name"]
|
|
precio = product["template."]["list_price"]["decimal"]
|
|
id_unit_measurement = product["default_uom."]["id"]
|
|
|
|
precios += f"- id: {id} - Nombre: {name}: ${precio} - ID Unidad de Medida: {id_unit_measurement}\n"
|
|
|
|
print(precios)
|
|
|
|
# Revisar disponibilidad de los productos
|
|
# print("=== Disponibilidad de los productos ===")
|
|
|
|
# response = catalog.search_products("Papa")
|
|
# disponibilidad: str = ""
|
|
|
|
# for product in response:
|
|
# id = product["id"]
|
|
# name = product["name"]
|
|
# stock = product["quantity"]
|
|
|
|
# disponibilidad += f"- id: {id} - Nombre: {name} - Stock: {stock}\n"
|
|
|
|
# print(disponibilidad)
|
|
|
|
|
|
|
|
# from langgraph_tools.tools.catalog.catalog_tools import (
|
|
# list_products,
|
|
# search_products,
|
|
# check_price,
|
|
# )
|
|
|
|
# def test_catalog_functions():
|
|
# print("=== Probando lista de productos ===")
|
|
# print(list_products())
|
|
# print("\n")
|
|
|
|
# print("=== Probando búsqueda de productos ===")
|
|
# print(search_products("Arroz"))
|
|
# print("\n")
|
|
|
|
# print("=== Probando verificación de precio ===")
|
|
# print(check_price("Arroz"))
|
|
# print("\n")
|
|
|
|
# if __name__ == "__main__":
|
|
# test_catalog_functions() |