bemade-addons/helpdesk_sale_order_ai/migrations/15.0.1.0/pre-migrate.py
mathis ed9dda9bea [ADD] openwebui_connector, helpdesk_sale_order_ai: AI-powered sales order generation from helpdesk tickets
This commit introduces AI integration for helpdesk tickets to automatically generate sales orders:

- openwebui_connector: New module providing integration with OpenWebUI AI service
  * Configurable API connection (key, base URL, model)
  * AI prompt template system for reusable prompts
  * Uses Claude 3 Sonnet model by default

- helpdesk_sale_order_ai: Extends helpdesk_sale_order with AI capabilities
  * AI-powered analysis of ticket content to suggest products
  * Smart product quantity parsing from various formats
  * Dedicated UI tab for AI suggestions in helpdesk tickets
  * Auto-creation of sales orders with matched products

The integration streamlines the process of converting customer support requests into sales opportunities.
2025-07-15 15:18:01 -04:00

43 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
import logging
_logger = logging.getLogger(__name__)
def migrate(cr, version):
"""
Migrate system parameters from helpdesk OpenWebUI client to centralized OpenAI client
"""
if not version:
return
_logger.info("Starting migration of OpenWebUI configuration parameters")
# Map of old parameter keys to new parameter keys
param_mapping = {
'openwebui.api_key': 'openai.api_key',
'openwebui.base_url': 'openai.base_url',
'openwebui.model': 'openai.model',
}
# For each parameter, check if it exists and migrate it if needed
for old_key, new_key in param_mapping.items():
# Check if the old parameter exists
cr.execute("SELECT value FROM ir_config_parameter WHERE key = %s", (old_key,))
old_value = cr.fetchone()
if old_value and old_value[0]:
# Check if the new parameter already exists
cr.execute("SELECT value FROM ir_config_parameter WHERE key = %s", (new_key,))
new_value = cr.fetchone()
if not new_value or not new_value[0]:
# New parameter doesn't exist or is empty, set it to the old value
_logger.info(f"Migrating parameter {old_key} to {new_key} with value {old_value[0]}")
cr.execute("""
INSERT INTO ir_config_parameter (key, value)
VALUES (%s, %s)
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value
""", (new_key, old_value[0]))
_logger.info("Migration of OpenWebUI configuration parameters completed")