Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] fs_attachment: Avoid error on url compute #302

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fs_attachment/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Base Attachment Object Store
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6ae379e8e8c8bea3d8c3452da7f64b766a5a1c816c388340a4b3d732730e683f
!! source digest: sha256:ec779601ef6dc2ae2d25d7a9339390881be25ced9802ffc9611abbfd7a9d05e5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
4 changes: 3 additions & 1 deletion fs_attachment/models/fs_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ def _get_url_for_attachment(
# always remove the directory_path from the fs_filename
# only if it's at the start of the filename
fs_filename = attachment.fs_filename
if fs_filename.startswith(fs_storage.directory_path):
if fs_storage.directory_path and fs_filename.startswith(
fs_storage.directory_path
):
fs_filename = fs_filename.replace(fs_storage.directory_path, "")
parts = [base_url, fs_filename]
return self._normalize_url("/".join(parts))
Expand Down
1 change: 1 addition & 0 deletions fs_attachment/readme/newsfragments/302.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix error when an url is computed for an attachment in a storage configure wihtout directory path.
2 changes: 1 addition & 1 deletion fs_attachment/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Base Attachment Object Store</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6ae379e8e8c8bea3d8c3452da7f64b766a5a1c816c388340a4b3d732730e683f
!! source digest: sha256:ec779601ef6dc2ae2d25d7a9339390881be25ced9802ffc9611abbfd7a9d05e5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/storage/tree/16.0/fs_attachment"><img alt="OCA/storage" src="https://img.shields.io/badge/github-OCA%2Fstorage-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/storage-16-0/storage-16-0-fs_attachment"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/storage&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>In some cases, you need to store attachment in another system that the Odoo’s
Expand Down
Loading