Force DB For Default Attachment Rules: This option is useful if
you want to force the storage of some attachments in the database,
even if you have a default filesystem storage configured. This is
specially useful when you’re using a storage backend like S3, where
the latency of the network can be high. This option is a JSON field
that allows you to define the mimetypes and the size limit below which
the attachments will be stored in the database.
Small images (128, 256) are used in Odoo in list / kanban views. We
want them to be fast to read. They are generally < 50KB (default
configuration) so they don’t take that much space in database, but
they’ll be read much faster than from the object storage.
The assets (application/javascript, text/css) are stored in database
as well whatever their size is:
- a database doesn’t have thousands of them
- of course better for performance
- better portability of a database: when replicating a production
instance for dev, the assets are included
The default configuration is:
{“image/”: 51200, “application/javascript”: 0, “text/css”: 0}
Where the key is the beginning of the mimetype to configure and the
value is the limit in size below which attachments are kept in DB.
0 means no limit.
Default configuration means:
- images mimetypes (image/png, image/jpeg, …) below 50KB are stored
in database
- application/javascript are stored in database whatever their size
- text/css are stored in database whatever their size
The rules can also be grouped by rule name:
- mimetype-size: the mimetype rules described above
- field-size: the key is a <model>.<field> pair, to force the
storage in database of the attachments of a specific binary field,
whatever their mimetype
It’s useful for fields like the menu icons, that are read on every
page load, without having to keep all the images in database:
{“mimetype-size”: {“image/”: 51200, “application/javascript”: 0,
“text/css”: 0}, “field-size”: {“ir.ui.menu.web_icon_data”: 0}}
Keys that are not a rule name are read as mimetype rules, so existing
configurations keep working.
A field rule is checked before the mimetype rules: if the attachment
matches it and is within its limit, it is stored in database,
otherwise the mimetype rules apply.
This option is only available on the filesystem storage that is used
as default for attachments.