/** * WPML compatibility functions * * @global array $duplicated_posts Array to store the posts being duplicated. * * @package Yoast\WP\Duplicate_Post * @since 3.2 */ add_action( 'admin_init', 'duplicate_post_wpml_init' ); /** * Add handlers for WPML compatibility. */ function duplicate_post_wpml_init() { if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { add_action( 'dp_duplicate_page', 'duplicate_post_wpml_copy_translations', 10, 3 ); add_action( 'dp_duplicate_post', 'duplicate_post_wpml_copy_translations', 10, 3 ); add_action( 'shutdown', 'duplicate_wpml_string_packages', 11 ); } } global $duplicated_posts; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: Renaming a global variable is a BC break. $duplicated_posts = []; /** * Copy post translations. * * @global SitePress $sitepress Instance of the Main WPML class. * @global array $duplicated_posts Array of duplicated posts. * * @param int $post_id ID of the copy. * @param WP_Post $post Original post object. * @param string $status Status of the new post. */ function duplicate_post_wpml_copy_translations( $post_id, $post, $status = '' ) { global $sitepress; global $duplicated_posts; remove_action( 'dp_duplicate_page', 'duplicate_post_wpml_copy_translations', 10 ); remove_action( 'dp_duplicate_post', 'duplicate_post_wpml_copy_translations', 10 ); $current_language = $sitepress->get_current_language(); $trid = $sitepress->get_element_trid( $post->ID ); if ( ! empty( $trid ) ) { $translations = $sitepress->get_element_translations( $trid ); $new_trid = $sitepress->get_element_trid( $post_id ); foreach ( $translations as $code => $details ) { if ( $code !== $current_language ) { if ( $details->element_id ) { $translation = get_post( $details->element_id ); if ( ! $translation ) { continue; } $new_post_id = duplicate_post_create_duplicate( $translation, $status ); if ( ! is_wp_error( $new_post_id ) ) { $sitepress->set_element_language_details( $new_post_id, 'post_' . $translation->post_type, $new_trid, $code, $current_language ); } } } } // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: see above. $duplicated_posts[ $post->ID ] = $post_id; } } /** * Duplicate string packages. * * @global array() $duplicated_posts Array of duplicated posts. */ function duplicate_wpml_string_packages() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: renaming the function would be a BC-break. global $duplicated_posts; foreach ( $duplicated_posts as $original_post_id => $duplicate_post_id ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter. $original_string_packages = apply_filters( 'wpml_st_get_post_string_packages', false, $original_post_id ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter. $new_string_packages = apply_filters( 'wpml_st_get_post_string_packages', false, $duplicate_post_id ); if ( is_array( $original_string_packages ) ) { foreach ( $original_string_packages as $original_string_package ) { $translated_original_strings = $original_string_package->get_translated_strings( [] ); foreach ( $new_string_packages as $new_string_package ) { $cache = new WPML_WP_Cache( 'WPML_Package' ); $cache->flush_group_cache(); $new_strings = $new_string_package->get_package_strings(); foreach ( $new_strings as $new_string ) { if ( isset( $translated_original_strings[ $new_string->name ] ) ) { foreach ( $translated_original_strings[ $new_string->name ] as $language => $translated_string ) { do_action( // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter. 'wpml_add_string_translation', $new_string->id, $language, $translated_string['value'], $translated_string['status'] ); } } } } } } } } Odoo×AI ファイルの説明 – Raqqa

Odoo×AI ファイルの説明

📁 プロジェクトフォルダ構成とファイルの説明

🔷 /odoo/

  • postgres-deployment.yaml
    • Odoo/Metabase 共用の Postgres デプロイメント(DB用)
    • create-metabase-db.sqlを初期化スクリプトとして使用
  • create-metabase-db.sql
    • Postgres起動時にmetabaseというDBを作成するSQLスクリプト
  • pvc-postgres.yaml
    • Postgresデータ保存用の永続ボリューム(PVC)

🔷 /metabase/

  • metabase-deployment.yaml
    • Metabase本体のPod定義(内部DBはPostgresのmetabase DBを使用)
  • metabase-service.yaml
    • MetabaseのService(ポート3000)
  • metabase-secret.yaml
    • Metabase初期ログイン用ユーザー名・パスワード等を定義したSecret
  • metabase-pvc.yaml
    • Metabaseの永続データ(設定・ダッシュボード)の保存用PVC

🔷 /openai/

  • main.py
    • FastAPIアプリ。以下のエンドポイントを提供:
      • /generate-sql:自然言語からSQL生成
      • /ask-odoo:OdooマニュアルのQA対応
      • /run-sql:SQLをMetabaseに実行し、グラフURLと解説を返す
  • metabase_query.py
    • MetabaseのAPIを使ってSQLを実行・カード(グラフ)を作成
  • openai-deployment.yaml
    • OpenAI APIとの接続用Pod
    • ChromaDBとMetabase APIに対応
  • save_metadata.py
    • OdooのDB構造をjson化して /chroma/db_metadata.json に保存
  • chroma/
    • ChromaDBの永続保存先(Odooマニュアルのベクトル検索用)

✅ このシステムで実現できること(総合まとめ)

このプロジェクトは以下のような自然言語ベースの業務支援AIシステムを構築するものです:

🎯 自然言語 → SQL → グラフ → 解説

  1. 自然言語で質問
  2. OpenAIでSQLを自動生成(対象テーブルに沿った安全な構文)
  3. MetabaseにSQLを実行、グラフを作成
  4. 作成されたグラフURLと、OpenAIによるグラフの意味・解説を自動出力
  5. フロントエンドでは iframe によるグラフ表示も可能

💡 導入メリット・訴求点

  • リリース時にマニュアルを読むことなく使えるUI/UX
  • データ検索~グラフ化~解釈~次のアクション提案まで一貫自動化
  • カスタマイズさえすれば「ERPのデータ可視化+AIレコメンド基盤」をすぐ提供可能
  • 運用コストはKubernetes上のPod運用のみ。継続課金型ビジネスにも転用可能

英語

Here’s the folder and file explanation in English, along with a summary of what the system does, suitable for sharing with offshore teams or in a next project thread.


📁 Project Folder Structure & File Descriptions

🔷 /odoo/

  • postgres-deployment.yaml
    • Deployment file for shared Postgres (used by both Odoo and Metabase)
    • Executes create-metabase-db.sql to create metabase DB on startup
  • create-metabase-db.sql
    • SQL script to create the metabase database
  • pvc-postgres.yaml
    • Persistent Volume Claim (PVC) for storing Postgres data

🔷 /metabase/

  • metabase-deployment.yaml
    • Pod definition for Metabase, using metabase DB on shared Postgres
  • metabase-service.yaml
    • Service exposing Metabase on port 3000
  • metabase-secret.yaml
    • Secret containing Metabase initial login credentials
  • metabase-pvc.yaml
    • PVC for saving Metabase dashboards and settings

🔷 /openai/

  • main.py
    • FastAPI app with the following endpoints:
      • /generate-sql: Generates SQL from natural language questions
      • /ask-odoo: Answers Odoo-related questions using ChromaDB
      • /run-sql: Executes SQL on Metabase and returns chart URL with OpenAI explanation
  • metabase_query.py
    • Script that sends SQL to Metabase via API and generates chart cards
  • openai-deployment.yaml
    • Pod to run the OpenAI integration service
    • Connects to ChromaDB and Metabase API
  • save_metadata.py
    • Extracts database schema from Odoo and saves it as db_metadata.json
  • chroma/
    • Persistent storage directory for ChromaDB (used for Odoo documentation embeddings)

✅ What This System Does (Summary)

This project builds a natural language-driven analytics assistant using OpenAI, Metabase, and FastAPI:

🎯 Flow: Natural Language → SQL → Chart → Explanation

  1. User asks a question in natural language
  2. OpenAI generates appropriate SQL based on schema metadata
  3. SQL is executed on Metabase, and a chart is created
  4. The chart URL is returned along with an automatic explanation by OpenAI
  5. In the frontend, the chart can be embedded using iframe

💡 Business Value & Use Case

  • No need to manually write SQL or design charts
  • Fully automated pipeline from data query to interpretation
  • Ideal for building a “smart ERP analytics frontend”
  • Can be converted into a SaaS offering by charging for:
    • Usage per query
    • AI interpretation
    • Custom dashboard templates

Let me know if you’d like this turned into a slide deck or a Markdown README for your GitHub repo.


Comments

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です