Skip to content

[19.0][ADD] ai_sale_product_matcher: find best-matched PIM products from requirement docs/images using AI - #106

Open
volkantasci wants to merge 23 commits into
OCA:19.0from
volkantasci:19.0-add-ai-sale-product-matcher
Open

[19.0][ADD] ai_sale_product_matcher: find best-matched PIM products from requirement docs/images using AI#106
volkantasci wants to merge 23 commits into
OCA:19.0from
volkantasci:19.0-add-ai-sale-product-matcher

Conversation

@volkantasci

Copy link
Copy Markdown

Adds ai_sale_product_matcher — find best-matched PIM products from requirement docs/images using a vision LLM.

What it does

Upload a spec sheet, email screenshot or type requirements (e.g. "120 bar soğuk sulu, monofaze, 2.3kW, deterjan tanklı") — the module extracts a canonical requirements JSON using the same ai_connection openai_compatible vision pipeline as ai_document_extraction (only prompts differ), then scores all product.template records against the PIM attribute catalog (katalog-sablonu.json → 232 keys) with type-aware matching (range, tolerance, fuzzy, directional en az/en fazla) and weighted groups. Top 10 matches are shown on the Sale Order with match % and can be added as order lines.

Sales integration: sale.orderFind Products with AI wizard (file + text → Extract → editable JSON → Find Matches → Add to Order). Extraction runs via queue_job + bus so UI never blocks.

Key features:

  • Vision LLM extraction (PDF/image with pdf2image/Pillow preprocessing, multi-page support, live PIM key set in prompt, English prompts sector-independent)
  • Type-aware product matching (exact/range/tolerance + missing-neutral scoring, Brand/Category optional filter)
  • Ranked results (matched count first, then weighted % — ideal product is top)
  • Async via queue_job + bus (non-blocking wizard)
  • Full queue_job/bus/ai_connection deps, ACL, i18n (TR), tests

Technical notes

  • Depends on sale, product, bus, queue_job, ai_connection, ai_tool (same stack as ai_document_extraction).
  • Uses ai_connection OpenAI-compatible client; prompts filtered to non-null keys to avoid truncation/401.
  • Tests mock LLM at service boundary (test_product_matcher, test_requirement_extractor).
  • Follows OCA 19.0 scaffolding (readme fragments, ir.model.access.csv, AGPL-3).

cc @OCA/ai-maintainers

…racted text (fix empty extraction for spec sheets)
@oca-cla-bot

oca-cla-bot Bot commented Aug 22, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

…-file lint ignores

- Wrap over-long lines instead of ignoring E501 repo-wide
- Split _validate_requirements per-type coercion into helpers (C901),
  behavior verified identical against the previous implementation
- Log swallowed exceptions instead of bare except-pass (W8138)
- Drop redundant field strings equal to field name (W8113)
Regenerated the .pot from Odoo 19 (i18n export) so it matches the current
code (new filter fields, selection values, reworded messages). Deduplicated
repeated msgids in tr.po, dropped a stale field reference, and msgmerged
translations against the new template.
@volkantasci

Copy link
Copy Markdown
Author

All pre-commit checks are now green (prettier, eslint, ruff, ruff-format, pylint-odoo mandatory, OCA po/module checks):

  • XML views, JS and readme formatted with the repo's prettier config
  • JS asset renamed to sale_order_ai_matcher.esm.js so eslint parses it as a module
  • Repo-wide .ruff.toml per-file ignores removed: long lines wrapped, _validate_requirements split into per-type coercion helpers (behavior verified identical), swallowed exceptions now logged, redundant field strings dropped
  • Removed a machine-specific fallback path from catalog_schema.py
  • .pot regenerated from Odoo 19 and tr.po deduplicated/msgmerged; requirements.txt added

Module tests run locally (Odoo 19, scratch DB with ai_connection, ai_tool, queue_job installed): 12/12 pass, 0 failures.

The tests workflow remains red only because odoo-addon-ai_connection==19.0.* / odoo-addon-ai_tool==19.0.* are not on the wheelhouse yet — they will be published when #100 merges, after which I will rebase this PR.

@volkantasci

Copy link
Copy Markdown
Author

Note: the base dependency PR #100 was restructured per the OCA migration guidelines into #110 (ai_tool) and #111 (ai_connection). The tests/runboat failures here remain blocked on those wheels being published, after which I will rebase.

@volkantasci

Copy link
Copy Markdown
Author

Update on the dependency chain: ai_tool was migrated to 19.0 and merged via #101 (its 19.0 wheel is already published). The remaining dependency is the ai_connection migration, now open as #111 (fully green: pre-commit, Odoo/OCB tests, codecov, runboat). Once #111 merges I will rebase this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:ai_sale_product_matcher Module ai_sale_product_matcher series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants