[14.0][ADD] account_invoice_import_invoice2data_db_templates - #1372
Open
bosd wants to merge 2 commits into
Open
Conversation
Back-port of the 16.0 module (in review at OCA#1365) to 14.0. The parent addon account_invoice_import_invoice2data already exists on 14.0, so this can land without depending on the 16.0 migration PR (OCA#1220). Same shape as the 16.0 version: - `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 (invoice2data#497) and `extract_number` flag (invoice2data#652) exposed as first-class columns. - Form actions: Preview text, Test (full extract_data() vs chatter PDF), 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. - 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. Differences from the 16.0 version: - `_inherit = ["mail.thread", "mail.activity.mixin"]` -- both mixins exist on 14.0. - Dropped the `web_ribbon` widget from the form view (14.0 has no built-in web_ribbon widget yet). Requires invoice2data >= 1.0 for `ordered_load`, `suggested_template`, per-field `replace` / `extract_number`.
Three CI-red fixes: - Test: `TransactionCase.setUpClass` doesn't set `cls.env` on 14.0 (only `SavepointCase` does), so `cls.Template = cls.env[...]` blew up with `AttributeError: type object 'TestInvoice2dataDBTemplates' has no attribute 'env'`. Move the fixture binding to `setUp` (instance). - Black reformat on the models / wizard / tests to satisfy the OCA pre-commit hook. - Add the OCA-required setup/account_invoice_import_invoice2data_db_templates scaffolding (auto-generated by `setuptools-odoo-make-default`).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
A new addon,
account_invoice_import_invoice2data_db_templates, that stores invoice2data templates in the Odoo database and merges them into the import wizard alongside the existing disk-loaded ones. Implements the GUI template builder the parent module's 2017 TODO list asked for.14.0 back-port of #1365 (16.0). The parent module
account_invoice_import_invoice2dataalready exists on 14.0, so this can land without depending on the 16.0 migration.Authoring modes
field_idso2m; JSON is composed at save time.The canonical field-name selection list is driven from
invoice2data.extract.schema— adding a new canonical field upstream automatically becomes selectable here.Buttons on the form
to_texton the latest chatter attachment.extract_data()against the attached PDF using this template + the disk-loaded ones.invoice2data.extract.template_builder.suggested_template+ the label-detection helpers to pre-fill the field grid from the latest attached PDF.First-class support for the 1.0 lib options
Per-field
replace(invoice2data#497) andextract_numberflag (invoice2data#652) are exposed as columns on the o2m, not buried in JSON.Differences from the 16.0 module
web_ribbonwidget (14.0 has no built-in web_ribbon).External dependency
invoice2data >= 1.0(now on PyPI). The 1.0 cut includesordered_load,suggested_template, per-fieldreplace, and theextract_numberfield option this module surfaces.Reviewers
cc @alexis-via — happy to rebase / split / squash per your preferences.