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.
38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from . import models
|
|
from . import views
|
|
|
|
def post_init_hook(cr, registry=None):
|
|
"""Initialize default AI prompt template after module installation
|
|
|
|
Note: This function can be called with either one argument (env) or two arguments (cr, registry)
|
|
to accommodate different Odoo hook calling conventions.
|
|
"""
|
|
import logging
|
|
_logger = logging.getLogger(__name__)
|
|
_logger.info("=== START: post_init_hook ====")
|
|
|
|
try:
|
|
from odoo import api, SUPERUSER_ID
|
|
|
|
# Handle different calling conventions
|
|
if hasattr(cr, 'env'): # cr is actually an env
|
|
env = cr
|
|
_logger.info("Using provided environment")
|
|
elif registry: # We have both cr and registry
|
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
|
_logger.info("Created environment from cursor and registry")
|
|
else:
|
|
_logger.warning("Cannot create environment, skipping template creation")
|
|
return
|
|
|
|
_logger.info("Calling _ensure_default_template")
|
|
env['openwebui.prompt.template']._ensure_default_template('helpdesk')
|
|
_logger.info("Default template ensured successfully")
|
|
_logger.info("=== END: post_init_hook ====")
|
|
except Exception as e:
|
|
_logger.error(f"ERROR in post_init_hook: {str(e)}")
|
|
_logger.exception("Exception traceback:")
|
|
# Don't raise the exception to prevent installation failure
|
|
return
|