diff --git a/README.md b/README.md
index 65f1eb90fc9..815e3b6e1d9 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ Available addons
----------------
addon | version | maintainers | summary
--- | --- | --- | ---
-[attachment_unindex_content](attachment_unindex_content/) | 19.0.1.0.0 |
| Disable indexing of attachments
+[attachment_unindex_content](attachment_unindex_content/) | 19.0.1.0.1 |
| Disable indexing of attachments
[auditlog](auditlog/) | 19.0.2.0.1 | | Audit Log
[auto_backup](auto_backup/) | 19.0.1.0.1 | | Backups database
[base_cron_exclusion](base_cron_exclusion/) | 19.0.1.0.0 |
| Allow you to select scheduled actions that should not run simultaneously.
@@ -32,7 +32,7 @@ addon | version | maintainers | summary
[base_search_fuzzy](base_search_fuzzy/) | 19.0.1.0.0 | | Fuzzy search with the PostgreSQL trigram extension
[base_technical_user](base_technical_user/) | 19.0.1.0.0 | | Add a technical user parameter on the company
[base_time_window](base_time_window/) | 19.0.1.0.0 | | Base model to handle time windows
-[base_view_inheritance_extension](base_view_inheritance_extension/) | 19.0.1.0.0 |
| Adds more operators for view inheritance
+[base_view_inheritance_extension](base_view_inheritance_extension/) | 19.0.1.0.1 |
| Adds more operators for view inheritance
[base_write_diff](base_write_diff/) | 19.0.1.0.0 | | Prevents updates on fields whose values won't change anyway
[bus_alt_connection](bus_alt_connection/) | 19.0.1.0.0 | | Needed when using PgBouncer as a connection pooler
[database_cleanup](database_cleanup/) | 19.0.1.0.6 | | Database cleanup
@@ -46,7 +46,7 @@ addon | version | maintainers | summary
[scheduler_error_mailer](scheduler_error_mailer/) | 19.0.1.0.0 | | Scheduler Error Mailer
[sentry](sentry/) | 19.0.1.0.1 |
| Report Odoo errors to Sentry
[sequence_python](sequence_python/) | 19.0.1.0.0 | | Calculate a sequence number from a Python expression
-[session_db](session_db/) | 19.0.1.0.0 |
| Store sessions in DB
+[session_db](session_db/) | 19.0.1.0.1 |
| Store sessions in DB
[test_auditlog](test_auditlog/) | 19.0.2.0.0 | | Additional unit tests for Audit Log based on accounting models
[tracking_manager](tracking_manager/) | 19.0.1.0.1 |
| This module tracks all fields of a model, including one2many and many2many ones.
[tracking_manager_domain](tracking_manager_domain/) | 19.0.1.0.0 |
| This module extends the tracking manager to allow to define a domain on fields to track changes only when certain conditions apply.
diff --git a/attachment_unindex_content/README.rst b/attachment_unindex_content/README.rst
index 4e1ef159110..31d016bdbf2 100644
--- a/attachment_unindex_content/README.rst
+++ b/attachment_unindex_content/README.rst
@@ -11,7 +11,7 @@ Attachment Unindex Content
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !! source digest: sha256:f84f73f35e674b364f6912293285a59b1a761c2cf472c767a474af77c1fe72db
+ !! source digest: sha256:e1db1411f492f69fbf8123a433f2487ed5b67aab4be06ca0dccea5d48e37e54d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -65,6 +65,15 @@ it at ``ir.attachment`` base.
Also, after the installation, the ``index_content`` field on attachments
already recorded in database will be cleared.
+Nothing is stored, but the field is still readable: when the database
+has no content for an attachment, reading ``index_content`` indexes the
+file at that moment and puts the result in the cache only. Code that
+reads the field, as the website does to find a color in the CSS bundle,
+keeps working with no copy of the content in the database. The cost is
+reading the file of every attachment whose ``index_content`` is
+requested. Searching on the field still finds nothing, because the
+column stays empty.
+
.. |SQL Query result showing indexed content| image:: https://user-images.githubusercontent.com/442938/67894113-45d27a80-fb2e-11e9-9a22-ba43d8b444c5.png
:target: https://user-images.githubusercontent.com/442938/67894113-45d27a80-fb2e-11e9-9a22-ba43d8b444c5.png
diff --git a/attachment_unindex_content/__manifest__.py b/attachment_unindex_content/__manifest__.py
index dda7a4ff189..3981b32ba43 100644
--- a/attachment_unindex_content/__manifest__.py
+++ b/attachment_unindex_content/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Attachment Unindex Content",
"summary": "Disable indexing of attachments",
- "version": "19.0.1.0.0",
+ "version": "19.0.1.0.1",
"author": "Vauxoo, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-tools",
"maintainers": [
diff --git a/attachment_unindex_content/models/ir_attachment.py b/attachment_unindex_content/models/ir_attachment.py
index 772e38ce20e..54b37196d8d 100644
--- a/attachment_unindex_content/models/ir_attachment.py
+++ b/attachment_unindex_content/models/ir_attachment.py
@@ -10,3 +10,31 @@ class IrAttachment(models.Model):
@api.model
def _index(self, *args, **kwargs):
return False
+
+ def _fetch_query(self, query, fields):
+ """Give ``index_content`` the content of the file when the database has none.
+
+ The content is not stored, so the column is empty, but whoever reads the field
+ still needs its value: core reads it to look a color up in the CSS bundle of the
+ website. Read it from the file, as the indexation would have stored it, and only
+ put it in the cache: nothing is written to the database.
+ """
+ fetched = super()._fetch_query(query, fields)
+ field = self._fields["index_content"]
+ if fetched and field in fields:
+ cache = field._get_cache(self.env)
+ for attachment in fetched:
+ if cache.get(attachment.id):
+ continue
+ content = self._index_content_from_file(attachment)
+ if content:
+ field._update_cache(attachment, content)
+ return fetched
+
+ def _index_content_from_file(self, attachment):
+ """Return what the indexation would have stored for ``attachment``."""
+ raw = attachment.raw
+ if not raw:
+ return False
+ # Skip this class: it is the one that disables the indexation
+ return super()._index(raw, attachment.mimetype, checksum=attachment.checksum)
diff --git a/attachment_unindex_content/readme/DESCRIPTION.md b/attachment_unindex_content/readme/DESCRIPTION.md
index b9a3937441c..36ceee2c777 100644
--- a/attachment_unindex_content/readme/DESCRIPTION.md
+++ b/attachment_unindex_content/readme/DESCRIPTION.md
@@ -29,3 +29,11 @@ it at `ir.attachment` base.
Also, after the installation, the `index_content` field on attachments
already recorded in database will be cleared.
+
+Nothing is stored, but the field is still readable: when the database has
+no content for an attachment, reading `index_content` indexes the file at
+that moment and puts the result in the cache only. Code that reads the
+field, as the website does to find a color in the CSS bundle, keeps working
+with no copy of the content in the database. The cost is reading the file
+of every attachment whose `index_content` is requested. Searching on the
+field still finds nothing, because the column stays empty.
diff --git a/attachment_unindex_content/static/description/index.html b/attachment_unindex_content/static/description/index.html
index 0a576fc1bff..b8cfdcef421 100644
--- a/attachment_unindex_content/static/description/index.html
+++ b/attachment_unindex_content/static/description/index.html
@@ -3,7 +3,7 @@