Skip to content

[MIG] account_invoice_import_invoice2data: Migration to 16.0#1220

Open
MarwanBHL wants to merge 99 commits into
OCA:16.0from
MarwanBHL:16.0-mig-account_invoice_import_invoice2data
Open

[MIG] account_invoice_import_invoice2data: Migration to 16.0#1220
MarwanBHL wants to merge 99 commits into
OCA:16.0from
MarwanBHL:16.0-mig-account_invoice_import_invoice2data

Conversation

@MarwanBHL

@MarwanBHL MarwanBHL commented Oct 2, 2025

Copy link
Copy Markdown

Migration based on the PR #753

depends account_invoice_import

@MarwanBHL MarwanBHL changed the title [WIP][MIG] account_invoice_import_invoice2data: Migration to 16.0 [MIG] account_invoice_import_invoice2data: Migration to 16.0 Oct 3, 2025
@MarwanBHL
MarwanBHL marked this pull request as ready for review October 3, 2025 13:00
@MarwanBHL
MarwanBHL force-pushed the 16.0-mig-account_invoice_import_invoice2data branch 2 times, most recently from c38fe88 to 9486595 Compare November 23, 2025 00:04
@MarwanBHL
MarwanBHL marked this pull request as draft November 24, 2025 12:10
@MarwanBHL
MarwanBHL force-pushed the 16.0-mig-account_invoice_import_invoice2data branch from d82bc56 to a8d9f12 Compare December 18, 2025 16:59
@MarwanBHL
MarwanBHL force-pushed the 16.0-mig-account_invoice_import_invoice2data branch 2 times, most recently from 8151de3 to 76dd837 Compare December 30, 2025 15:43
@MarwanBHL
MarwanBHL force-pushed the 16.0-mig-account_invoice_import_invoice2data branch from 76dd837 to 8147065 Compare January 6, 2026 22:36
alexis-via and others added 20 commits February 19, 2026 10:02
…edicated module account_invoice_import_invoice2data

Update README.rst and headers to latest OCA conventions.
Better key names in the parsed_inv dict
parsed_inv doesn't need to be JSON serializable anymore (small drawback: the invoice is parsed a second time on the second step... but the second step is rarely used)
Move code from account_invoice_import_invoice2data to account_invoice_import
Update REAME and some interface strings about UBL being an ISO standard
Small code changes
…voice dict, cleaner organisation)

Code refactoring: move code in base_business_document_import, factorise code for tax matching (it was duplicated in UBL and ZUGFeRD)
Now support PDF with embedded UBL XML file
Enable unittests on account_invoice_import_ubl
More absolute xpath in account_invoice_import_ubl instead of relative xpath

WARNING: these are big changes, I may have broken a few details
…te dir and the built-in templates

Also allow to use only a local template dir
README updated to explain how to configure all this
Special thanks to Sébastien Beau for his help to achieve this
Add support for partner bank matching on invoice update (before, it was only supported on invoice creation)
[FIX] LINT

Use try/except when importing external libs
Remove self.ensure_one() that has nothing to do in an api.model method
…a recent version of pdftotext on travis's ubuntu 12.04 images
Rename __openerp__.py to __manifest__.py and set installable to False
Also port all the modules that generate the XML documents: account_invoice_ubl, account_invoice_zugferd, purchase_order_ubl and sale_order_ubl
… module

Fix spelling mistake and other remarks on README by Tarteo
simahawk and others added 7 commits February 19, 2026 10:02
DISABLED_MAIL_CONTEXT is not available yet in v14 and v15.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: edi-14.0/edi-14.0-account_invoice_import_invoice2data
Translate-URL: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-account_invoice_import_invoice2data/
Add support for discount on lines in the multi-line create scenario
@MarwanBHL
MarwanBHL force-pushed the 16.0-mig-account_invoice_import_invoice2data branch from d5ce1aa to 007b588 Compare February 19, 2026 10:05
@MarwanBHL
MarwanBHL marked this pull request as ready for review February 19, 2026 10:11
@MarwanBHL

Copy link
Copy Markdown
Author

Hey @alexis-via and @bosd, could you review my PR when you get a chance?

Thanks for your time! 🙏

@bosd bosd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MarwanBHL — thanks for picking this up. The migration is faithful and tight; the tax line work in parse_invoice2data_taxes and the line preparation logic are nicely aligned with the canonical schema that invoice2data uses upstream.

A few inline comments below — one is a small code suggestion (a tempfile cleanup tweak), the others are docs/roadmap additions. Nothing here blocks the migration; happy to ship after these are in.

Items I'm deliberately deferring to follow-up PRs after this one lands (so this PR can stay a clean migration):

  • Adding a @unittest.skipUnless(shutil.which("pdftotext"), ...) decorator on test_import_free_invoice so local devs without poppler don't see false failures (CI runbots are fine — they have poppler installed). I'll open this as a small follow-up.
  • Wiring in the new invoice2data opt-ins once invoice2data 1.0 is published on PyPI (it's still on the upstream next branch). At that point a follow-up PR can opt into the input-backend cascade, the ai_fallback=True runtime LLM extraction, and the typed errors (NoTemplateFoundError / RequiredFieldsMissingError via raise_on_error=True). I've left a placeholder bullet in ROADMAP.rst (suggestion below) to reserve that work.
  • Re-attach the cleaned PDF to the Odoo invoice: invoice2data 1.0 will expose a pre_process_pdf(...) path that returns the deskewed/cleaned PDF together with its text, which lets the wizard save the cleaned (usually smaller) PDF back as the invoice attachment instead of the user-uploaded raw scan. Useful for storage size and for downstream OCR retries. Follow-up PR after 1.0 ships.
  • parse_invoice2data_taxes currently sets unece_categ_code = "" with a stale # AA comment. The right behavior is to honor a line_tax_code field when the template captures one. Better as its own small PR than dragging it into the migration.

Let me know if you'd prefer any of those pulled into this PR instead.

Comment thread account_invoice_import_invoice2data/readme/ROADMAP.rst
Comment thread account_invoice_import_invoice2data/readme/HISTORY.rst
@bosd

bosd commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@MarwanBHL Can you please squash these translation commits?
image

mymage and others added 3 commits July 16, 2026 22:31
Translated using Weblate (Italian)

Currently translated at 6.6% (1 of 15 strings)

Translation: edi-14.0/edi-14.0-account_invoice_import_invoice2data
Translate-URL: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-account_invoice_import_invoice2data/it/

Translated using Weblate (Italian)

Currently translated at 13.3% (2 of 15 strings)

Translation: edi-14.0/edi-14.0-account_invoice_import_invoice2data
Translate-URL: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-account_invoice_import_invoice2data/it/
@MarwanBHL
MarwanBHL force-pushed the 16.0-mig-account_invoice_import_invoice2data branch from 2860a46 to 446ff7c Compare July 16, 2026 22:38
@MarwanBHL
MarwanBHL marked this pull request as ready for review July 16, 2026 22:44
@MarwanBHL

Copy link
Copy Markdown
Author

Done it's working with the 1.0 @bosd

bosd pushed a commit to bosd/edi that referenced this pull request Jul 18, 2026
DB-stored invoice2data templates + GUI builder as a new addon that
depends on account_invoice_import_invoice2data (this PR is stacked on
top of OCA#1220).

- `invoice2data.template` model with two authoring modes: guided (name +
  keywords + `field_ids` o2m composing the JSON at read time) and power-
  user (paste a full invoice2data JSON template into a dedicated tab).
- Per-field `replace` pair (issue invoice2data#497) and `extract_number`
  flag (issue invoice2data#652) exposed as first-class columns.
- Form actions: Preview text, Test (full extract_data() vs chatter PDF),
  and Suggest fields (wires the lib's suggested_template + label detection
  to pre-fill the field grid).
- Wizard extension reimplements invoice2data_parse_invoice: builds the
  templates list via a `_invoice2data_collect_templates` hook that
  concatenates disk + DB. Uses `with NamedTemporaryFile(...)` + flush()
  (matches the review on OCA#1220).
- Security: dedicated 'Manage invoice2data templates' group.
- Tests: JSON round-trip, structured composition, replace pair,
  extract_number opt-in semantics, type/active filtering, wizard merge.

Selection lists are driven from invoice2data.extract.schema so adding a
new canonical field upstream automatically becomes selectable here.
bosd pushed a commit to bosd/edi that referenced this pull request Jul 19, 2026
…mplate test

test_import_free_invoice extracts text from a bundled PDF using invoice2data's
pdftotext backend. That backend needs the poppler pdftotext binary; on a dev
container without poppler-utils installed the extraction returns "" and the
template never matches, so this test fails with a hard-to-diagnose stale-import
error.

Gate the test with @unittest.skipUnless(shutil.which("pdftotext"), ...) so
local runs stay green when poppler is missing while CI (which installs
poppler-utils) still runs the test.

Follow-up to the review of OCA#1220.
bosd pushed a commit to bosd/edi that referenced this pull request Jul 19, 2026
…eads line_tax_code

The wizard's parse_invoice2data_taxes hardcoded unece_categ_code = "" with
a stale '# AA' comment, dropping any UNECE category code (S / AA / E / Z /
...) a template captured. The invoice2data canonical schema has a
line_tax_code field for exactly this; honor it when present, fall back to
"" for backwards compatibility.

Downstream account_invoice_import uses tax_categ_code in
account_move_line._match_taxes, so this makes the imported tax match a
purchase tax filtered by its UNECE category code.

Follow-up to the review of OCA#1220.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.