Skip to content

[20.0][MIG] attachment_unindex_content: Migration to 20.0 - #3873

Open
yabdelhamed wants to merge 42 commits into
OCA:20.0from
yabdelhamed:20.0-mig-attachment_unindex_content
Open

yabdelhamed wants to merge 42 commits into
OCA:20.0from
yabdelhamed:20.0-mig-attachment_unindex_content

Conversation

@yabdelhamed

Copy link
Copy Markdown

Migration of attachment_unindex_content to 20.0, done with the format-patch procedure from the migration guide, so the history and authors are kept.

Changes for 20.0:

  • Version bumped to 20.0.1.0.0.
  • ir.attachment has no datas field anymore in 20.0, so _check_contents rejected the attachments the tests created from base64. The tests now pass the same content as raw bytes, as Odoo's own tests do. The module code itself needed no change: _index, _fetch_query and the field cache helpers it uses have compatible signatures in 20.0.
  • Cherry-picked 14f4266 from 19.0, which adds the pdfminer.six warning of attachment_indexation to checklog-odoo.cfg. Without it, initialising the test database fails on that warning before the module is installed. I kept it as a separate commit so it can be split out if you'd rather add it to 20.0 on its own.

Tests, run locally with the CI images ghcr.io/oca/oca-ci/py3.12-odoo20.0 and py3.12-ocb20.0 against pgvector/pgvector:pg16, using oca_install_addons, oca_init_test_database and oca_run_tests:

  • Odoo: 0 failed, 0 error(s) of 11 tests.
  • OCB: 0 failed, 0 error(s) of 11 tests.
  • With the _index override reverted to super(), 7 of the 11 fail, so the tests still cover what the module does on 20.0.

pre-commit run -a passes.

Part of #3772.

ebirbe and others added 30 commits November 20, 2026 07:33
This module is intended to disable the indexation of data on the
ir.attachment model.

Attachment model has a field called 'index_content' where the content
of the attachment is read and stored directly in the database. This field is
useful in order to search content of a file. But most of cases it is not used,
so, you can install this module in order to:

- **Avoid Duplicating Data:** Because indexation extracts text content
from files and put it on the database in order it could be searched, but
this implies you have the file data in your `filestore` directory, and
also part (or sometimes all) of that data in your database too.
- **Improve Performance:** Since not all indexed files are plain text, they
require extra process to read them.

Maybe you could try to uninstall modules like `document` in order to
disable its indexation features, but you could face the uninstallation of other
modules that could be useful for you (e.g, `hr_recruitment` depends on that).

But even if you don't have `document` installed, you'd still have
plain text content indexation by default.

Using this module you will not require to uninstall any module to
disable the attachment content indexation, because we directly disable it at
`ir.attachment` base.
Currently translated at 100.0% (4 of 4 strings)

Translation: server-tools-14.0/server-tools-14.0-attachment_unindex_content
Translate-URL: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-attachment_unindex_content/es_AR/
Odoo introduced a new param `checksum` to the method `_index` on the
attachment model [1]. Since that param is not supported on this model,
the following error is now being raised:

    TypeError: _index() got an unexpected keyword argument 'checksum'

[1] odoo/odoo@3d59cc84
- Manifest's "Version" updated to "16.0.1.0.0"
- Translation files updated to new version
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-tools-16.0/server-tools-16.0-attachment_unindex_content
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-attachment_unindex_content/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-tools-16.0/server-tools-16.0-attachment_unindex_content
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-attachment_unindex_content/
Currently translated at 100.0% (1 of 1 strings)

Translation: server-tools-16.0/server-tools-16.0-attachment_unindex_content
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-attachment_unindex_content/es/
Currently translated at 100.0% (1 of 1 strings)

Translation: server-tools-16.0/server-tools-16.0-attachment_unindex_content
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-attachment_unindex_content/it/
moylop260 and others added 12 commits November 20, 2026 07:33
* Remove superfluous keys in the manifest
* Remove financed migrations by other companies
* Bump manifest version
… dependency

Without declaring explicit dependency,
Odoo did not guarantee its load order,
resulting in attachment content still being indexed
Currently translated at 100.0% (3 of 3 strings)

Translation: server-tools-19.0/server-tools-19.0-attachment_unindex_content
Translate-URL: https://translation.odoo-community.org/projects/server-tools-19-0/server-tools-19-0-attachment_unindex_content/it/
The module answers `_index` with False so nothing is stored in
`index_content`, and the field is then empty for every reader. Code that
needs the value gets a boolean, for instance the website controller that
looks a theme color up in the CSS bundle through
`asset.css().index_content`:

    TypeError: expected string or bytes-like object, got 'bool'

Keep the column empty, but when the field is fetched and the database has
no value, index the file at that moment with the next `_index` of the MRO
(the one the module disables) and only put the result in the cache. Nothing
is written to the database, searching the field gives the same as before,
and a value written by hand is kept.

The tests that checked that the field reads False now check the stored
column.
…n about missing pdfminer.six

The PDF indexation function is never called by the module `attachment_unindex_content`, so the package is not needed.
Related to https://github.com/odoo/odoo/blob/d15685304f47/addons/attachment_indexation/models/ir_attachment.py#L17
ir.attachment no longer has a datas field in 20.0, so the tests
create attachments from raw bytes.
@oca-cla-bot

oca-cla-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@OCA-git-bot OCA-git-bot added series:20.0 mod:attachment_unindex_content Module attachment_unindex_content labels Nov 20, 2026
@yabdelhamed yabdelhamed mentioned this pull request Nov 20, 2026
3 of 30 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:attachment_unindex_content Module attachment_unindex_content series:20.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.