Skip to content

Commit

Permalink
[FIX] fs_attachment: prevent recompute_urls from skipping records wit…
Browse files Browse the repository at this point in the history
…h res_field != False
  • Loading branch information
PabloEForgeFlow committed Jul 17, 2024
1 parent dcedd0d commit bf077eb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions fs_attachment/models/fs_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,18 @@ def recompute_urls(self) -> None:
in staging are done in a different directory and will not impact the
production.
"""
attachments = self.env["ir.attachment"].search(
[("fs_storage_id", "in", self.ids)]
)
# The weird "res_field = False OR res_field != False" domain
# is required! It's because of an override of _search in ir.attachment
# which adds ('res_field', '=', False) when the domain does not
# contain 'res_field'.
# https://github.com/odoo/odoo/blob/9032617120138848c63b3cfa5d1913c5e5ad76db/
# odoo/addons/base/ir/ir_attachment.py#L344-L347
domain = [
("fs_storage_id", "in", self.ids),
"|",
("res_field", "=", False),
("res_field", "!=", False),
]
attachments = self.env["ir.attachment"].search(domain)
attachments._compute_fs_url()
attachments._compute_fs_url_path()

0 comments on commit bf077eb

Please sign in to comment.