Commit b9a51a9
committed
[FIX] fs_attachment: reconcile fs_filename when datas/raw is rewritten
``ir.attachment.write`` only called ``_enforce_meaningful_storage_filename``
when ``name`` was in ``vals``. Every other code path that rewrites
attachment bytes without touching the name — asset-bundle regeneration,
ORM image field updates, inline kanban image writes, the
``_force_storage`` migration itself — replaces ``store_fname`` via
``_storage_file_write`` but leaves ``fs_filename`` / ``fs_storage_code``
/ ``fs_storage_id`` stale.
A stale ``NULL`` ``fs_filename`` defeats the gate in
``IrBinary._get_fs_attachment_for_field``, so base Odoo falls through
to ``Stream.from_attachment``. The base implementation passes the
raw ``store_fname`` (e.g. ``"azure_attachments://<hash>"``) straight
to ``os.stat``, which raises ``FileNotFoundError`` — user-visible as
500s on every ``/web/image/<res_model>/<id>/<field>`` call that
touches one of these records.
Observed on production 2026-04-20 → 2026-04-22: when a site flipped
``fs.storage.use_as_default_for_attachments`` to an ``abfs`` (Azure
Blob) backend, the Odoo deploy that followed regenerated thousands of
asset bundles and ran background image updates, every one via
``write({"datas": ...})``. 36,804 ``ir.attachment`` rows entered the
broken state in under 48 h and every ``/web/image`` hit for those
records returned 500 — assets included, so the webclient rendered as
a blank page in every browser.
Widen the guard to also fire on ``"datas"`` / ``"raw"`` so every
write that actually changes the bytes leaves ``fs_filename``
consistent with the new ``store_fname``.
``_enforce_meaningful_storage_filename`` is idempotent and already
no-ops when nothing needs to change, so the broader guard has no
downside for the existing ``"name"`` path.
Signed-off-by: TecnologiaIG <tecnologia@intensegroupgt.com>1 parent a482807 commit b9a51a9
3 files changed
Lines changed: 43 additions & 1 deletion
File tree
- fs_attachment
- models
- readme/newsfragments
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| 333 | + | |
| 334 | + | |
333 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
334 | 356 | | |
335 | 357 | | |
336 | 358 | | |
| |||
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
0 commit comments