diff --git a/fs_attachment/README.rst b/fs_attachment/README.rst index 8b18e81487..26635edb6b 100644 --- a/fs_attachment/README.rst +++ b/fs_attachment/README.rst @@ -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 diff --git a/fs_attachment/models/fs_storage.py b/fs_attachment/models/fs_storage.py index 02ddcd7260..39ea401f72 100644 --- a/fs_attachment/models/fs_storage.py +++ b/fs_attachment/models/fs_storage.py @@ -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)) diff --git a/fs_attachment/readme/newsfragments/302.bugfix b/fs_attachment/readme/newsfragments/302.bugfix new file mode 100644 index 0000000000..3fde440b42 --- /dev/null +++ b/fs_attachment/readme/newsfragments/302.bugfix @@ -0,0 +1 @@ +Fix error when an url is computed for an attachment in a storage configure wihtout directory path. diff --git a/fs_attachment/static/description/index.html b/fs_attachment/static/description/index.html index 16ee36f341..c40c40f011 100644 --- a/fs_attachment/static/description/index.html +++ b/fs_attachment/static/description/index.html @@ -367,7 +367,7 @@
In some cases, you need to store attachment in another system that the Odoo’s