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.
56 lines
2.3 KiB
Python
56 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# This migration script will run after the module update
|
|
# It will ensure the system parameters are properly set up
|
|
|
|
import logging
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
def migrate(cr, version):
|
|
"""
|
|
Ensure system parameters are properly set up after migration
|
|
"""
|
|
# Set default values for system parameters
|
|
cr.execute("""
|
|
INSERT INTO ir_config_parameter (key, value, create_date, write_date)
|
|
VALUES ('openwebui.base_url', 'https://ai.bemade.org/api', now(), now())
|
|
ON CONFLICT (key) DO NOTHING
|
|
""")
|
|
|
|
cr.execute("""
|
|
INSERT INTO ir_config_parameter (key, value, create_date, write_date)
|
|
VALUES ('openwebui.model', 'anthropic.claude-3-7-sonnet-latest', now(), now())
|
|
ON CONFLICT (key) DO NOTHING
|
|
""")
|
|
|
|
# Log the migration
|
|
cr.execute("""
|
|
INSERT INTO ir_logging(create_date, create_uid, name, type, dbname, level, message, path, line, func)
|
|
VALUES (now(), 1, 'openwebui_connector', 'server', current_database(), 'info',
|
|
'Post-migration: Set default system parameters',
|
|
'/addons/openwebui_connector/migrations/1.0/post-migration.py', 30, 'migrate')
|
|
""")
|
|
|
|
# Check if helpdesk_sale_order_ai module is installed
|
|
cr.execute("""
|
|
SELECT id FROM ir_module_module
|
|
WHERE name = 'helpdesk_sale_order_ai'
|
|
AND state = 'installed'
|
|
""")
|
|
|
|
if cr.fetchone():
|
|
_logger.info("helpdesk_sale_order_ai module is installed, ensuring parameters are set")
|
|
|
|
# Ensure the helpdesk AI parameter exists
|
|
cr.execute("""
|
|
INSERT INTO ir_config_parameter (key, value, create_date, write_date)
|
|
VALUES ('helpdesk_sale_order_ai.use_ai_sale_orders', 'False', now(), now())
|
|
ON CONFLICT (key) DO NOTHING
|
|
""")
|
|
|
|
# Log the migration
|
|
cr.execute("""
|
|
INSERT INTO ir_logging(create_date, create_uid, name, type, dbname, level, message, path, line, func)
|
|
VALUES (now(), 1, 'openwebui_connector', 'server', current_database(), 'info',
|
|
'Post-migration: Set default helpdesk AI parameters',
|
|
'/addons/openwebui_connector/migrations/1.0/post-migration.py', 50, 'migrate')
|
|
""")
|