[MIG] account_invoice_import_invoice2data: Migration to 16.0#1220
[MIG] account_invoice_import_invoice2data: Migration to 16.0#1220MarwanBHL wants to merge 99 commits into
Conversation
c38fe88 to
9486595
Compare
d82bc56 to
a8d9f12
Compare
8151de3 to
76dd837
Compare
76dd837 to
8147065
Compare
…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
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
d5ce1aa to
007b588
Compare
|
Hey @alexis-via and @bosd, could you review my PR when you get a chance? Thanks for your time! 🙏 |
bosd
left a comment
There was a problem hiding this comment.
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 ontest_import_free_invoiceso 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
nextbranch). At that point a follow-up PR can opt into the input-backend cascade, theai_fallback=Trueruntime LLM extraction, and the typed errors (NoTemplateFoundError/RequiredFieldsMissingErrorviaraise_on_error=True). I've left a placeholder bullet inROADMAP.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_taxescurrently setsunece_categ_code = ""with a stale# AAcomment. The right behavior is to honor aline_tax_codefield 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.
|
@MarwanBHL Can you please squash these translation commits? |
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/
2860a46 to
446ff7c
Compare
|
Done it's working with the 1.0 @bosd |
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.
…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.
…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.

Migration based on the PR #753
depends account_invoice_import