diff --git a/README.md b/README.md index 653dd618ec..c9d5bb15d2 100644 --- a/README.md +++ b/README.md @@ -21,18 +21,19 @@ Available addons ---------------- addon | version | maintainers | summary --- | --- | --- | --- -[fs_attachment](fs_attachment/) | 18.0.2.2.1 | lmignon | Store attachments on external object store -[fs_attachment_s3](fs_attachment_s3/) | 18.0.1.2.0 | lmignon | Store attachments into S3 complient filesystem +[fs_attachment](fs_attachment/) | 18.0.2.2.2 | lmignon | Store attachments on external object store +[fs_attachment_s3](fs_attachment_s3/) | 18.0.1.2.1 | lmignon | Store attachments into S3 complient filesystem [fs_file](fs_file/) | 18.0.1.0.0 | lmignon | Field to store files into filesystem storages [fs_folder](fs_folder/) | 18.0.2.0.0 | lmignon | A module to link to Odoo records and manage from record forms forlders from external file systems [fs_folder_demo](fs_folder_demo/) | 18.0.1.0.0 | | Demo for fs_folder addon [fs_folder_ms_drive](fs_folder_ms_drive/) | 18.0.2.0.0 | lmignon | Display and manage your files from Microsoft drives from within Odoo [fs_folder_webdav](fs_folder_webdav/) | 18.0.1.0.0 | jguenat | UI improvement when managing WebDAV folder [fs_image](fs_image/) | 18.0.1.0.0 | lmignon | Field to store images into filesystem storages +[fs_image_thumbnail](fs_image_thumbnail/) | 18.0.1.0.0 | lmignon | Generate and store thumbnail for images [fs_storage](fs_storage/) | 18.0.2.1.2 | | Implement the concept of Storage with amazon S3, sftp... [fs_storage_ms_drive](fs_storage_ms_drive/) | 18.0.2.0.0 | lmignon | Add the microsoft drives (OneDrive, Sharepoint) as a storage backend [image_tag](image_tag/) | 18.0.1.0.0 | | Image tag model -[microsoft_drive_account](microsoft_drive_account/) | 18.0.2.0.0 | lmignon | Link user with Microsoft +[microsoft_drive_account](microsoft_drive_account/) | 18.0.2.0.1 | lmignon | Link user with Microsoft [storage_backend](storage_backend/) | 18.0.1.0.0 | | Implement the concept of Storage with amazon S3, sftp... [storage_backend_ftp](storage_backend_ftp/) | 18.0.1.0.0 | | Implement FTP Storage [storage_backend_s3](storage_backend_s3/) | 18.0.1.1.0 | | Implement amazon S3 Storage diff --git a/fs_attachment/README.rst b/fs_attachment/README.rst index 8ae6109789..c13037b9d3 100644 --- a/fs_attachment/README.rst +++ b/fs_attachment/README.rst @@ -11,7 +11,7 @@ Base Attachment Object Store !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:ae07154d0c96f19cbe1f6760cb690b0eefdea57af89985620fac1eef5d52f5fb + !! source digest: sha256:2247c3bace615168d55c67d0dffed04dda62c77a89434b15d04934e8a1f78184 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/fs_attachment/__manifest__.py b/fs_attachment/__manifest__.py index 38076afcc7..7ce2868501 100644 --- a/fs_attachment/__manifest__.py +++ b/fs_attachment/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Base Attachment Object Store", "summary": "Store attachments on external object store", - "version": "18.0.2.2.1", + "version": "18.0.2.2.2", "author": "Camptocamp, ACSONE SA/NV, Odoo Community Association (OCA)", "license": "AGPL-3", "development_status": "Beta", diff --git a/fs_attachment/models/ir_attachment.py b/fs_attachment/models/ir_attachment.py index 6bafc7dedb..bf8cdee3ae 100644 --- a/fs_attachment/models/ir_attachment.py +++ b/fs_attachment/models/ir_attachment.py @@ -253,6 +253,18 @@ def _storage(self): storage = super()._storage() return storage + @api.depends("store_fname", "db_datas") + def _compute_raw(self): + """Always expose raw payload as bytes. + + Some callers (e.g. account EDI helpers) slice the value returned by + ``raw`` and crash when it is ``False`` for 0-byte attachments. + """ + res = super()._compute_raw() + false_attachments = self.filtered(lambda att: not att.raw) + false_attachments.raw = b"" + return res + @api.model_create_multi def create(self, vals_list): """ @@ -697,9 +709,10 @@ def _move_attachment_to_store(self): self.ensure_one() _logger.info("inspecting attachment %s (%d)", self.name, self.id) fname = self.store_fname - storage = fname.partition("://")[0] - if self._is_storage_disabled(storage): - fname = False + if fname: + storage = fname.partition("://")[0] + if self._is_storage_disabled(storage): + fname = False if fname: # migrating from filesystem filestore # or from the old 'store_fname' without the bucket name diff --git a/fs_attachment/static/description/index.html b/fs_attachment/static/description/index.html index 5c2b3e646c..21d18e4314 100644 --- a/fs_attachment/static/description/index.html +++ b/fs_attachment/static/description/index.html @@ -372,7 +372,7 @@

Base Attachment Object Store

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:ae07154d0c96f19cbe1f6760cb690b0eefdea57af89985620fac1eef5d52f5fb +!! source digest: sha256:2247c3bace615168d55c67d0dffed04dda62c77a89434b15d04934e8a1f78184 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/storage Translate me on Weblate Try me on Runboat

In some cases, you need to store attachment in another system that the diff --git a/fs_attachment/tests/test_fs_attachment.py b/fs_attachment/tests/test_fs_attachment.py index 22c186ecac..f52c3ec900 100644 --- a/fs_attachment/tests/test_fs_attachment.py +++ b/fs_attachment/tests/test_fs_attachment.py @@ -75,6 +75,12 @@ def test_create_attachment_with_meaningful_name(self): with attachment.open("rb") as f: self.assertEqual(f.read(), new_content) + def test_create_attachment_with_no_payload_has_bytes_raw(self): + attachment = self.ir_attachment_model.create({"name": "empty.txt"}) + + self.assertEqual(attachment.raw, b"") + self.assertEqual(attachment.file_size, 0) + def test_open_attachment_in_db(self): self.env["ir.config_parameter"].sudo().set_param("ir_attachment.location", "db") content = b"This is a test attachment in db" diff --git a/fs_attachment_s3/README.rst b/fs_attachment_s3/README.rst index 7aff512059..790b298e67 100644 --- a/fs_attachment_s3/README.rst +++ b/fs_attachment_s3/README.rst @@ -11,7 +11,7 @@ Fs Attachment S3 !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:bf3d6979d1fa1dfe833a4b2663355ad392483c090177a137920f33ebb47ff224 + !! source digest: sha256:1ba96137af8042fcf51cd02e691f65ee0f3f9b910bb61aed0f341bf5f027b034 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -123,6 +123,17 @@ directory name as bucket name, and the file path. Changelog ========= +18.0.1.2.1 (2026-05-27) +----------------------- + +Bugfixes +~~~~~~~~ + +- Allow to use a prefix path and bucket in the directory_path on + fs.storage When the directory_path parameter is configured as / the + presigned url generation failed with a botocore error: "Invalid bucket + name". (`#b17de9 `__) + 18.0.1.2.0 (2025-10-20) ----------------------- diff --git a/fs_attachment_s3/__manifest__.py b/fs_attachment_s3/__manifest__.py index 2b392fef93..f0228140aa 100644 --- a/fs_attachment_s3/__manifest__.py +++ b/fs_attachment_s3/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Fs Attachment S3", "summary": """Store attachments into S3 complient filesystem""", - "version": "18.0.1.2.0", + "version": "18.0.1.2.1", "license": "AGPL-3", "author": "ACSONE SA/NV,Odoo Community Association (OCA)", "website": "https://github.com/OCA/storage", diff --git a/fs_attachment_s3/models/ir_attachment.py b/fs_attachment_s3/models/ir_attachment.py index 7a63bf005e..8bdc2c94ac 100644 --- a/fs_attachment_s3/models/ir_attachment.py +++ b/fs_attachment_s3/models/ir_attachment.py @@ -59,18 +59,22 @@ def _get_s3_x_sendfile_path(self): storage = self.env["fs.storage"].sudo().get_by_code(storage_code) root_fs = storage._get_root_filesystem(fs) s3_client = root_fs.s3 - bucket_name = storage.get_directory_path().strip("/").rstrip("/") + # The directory path might contain the bucket and a prefix + # the part before the first "/" is the bucket + # the rest is the prefix + bucket_name, *prefix_parts = storage.get_directory_path().strip("/").split("/") + s3_key = "/".join(prefix_parts + [file_path.lstrip("/")]) if storage.s3_uses_signed_url_for_x_sendfile: file_url = storage._s3_call_generate_presigned_url( s3_client, "get_object", - Params={"Bucket": bucket_name, "Key": file_path}, + Params={"Bucket": bucket_name, "Key": s3_key}, ExpiresIn=storage.s3_signed_url_expiration, ) else: file_url = ( f"{s3_client.meta.endpoint_url.rstrip('/')}/" - f"{bucket_name}/{file_path.lstrip('/')}" + f"{bucket_name}/{s3_key.lstrip('/')}" ) parsed_url = urlparse(file_url) diff --git a/fs_attachment_s3/readme/HISTORY.md b/fs_attachment_s3/readme/HISTORY.md index 29b08db0e4..49ad776ffc 100644 --- a/fs_attachment_s3/readme/HISTORY.md +++ b/fs_attachment_s3/readme/HISTORY.md @@ -1,3 +1,12 @@ +## 18.0.1.2.1 (2026-05-27) + +### Bugfixes + +- Allow to use a prefix path and bucket in the directory_path on fs.storage + When the directory_path parameter is configured as / + the presigned url generation failed with a botocore error: "Invalid bucket name". ([#b17de9](https://github.com/OCA/storage/issues/b17de9)) + + ## 18.0.1.2.0 (2025-10-20) ### Features diff --git a/fs_attachment_s3/readme/newsfragments/.gitkeep b/fs_attachment_s3/readme/newsfragments/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/fs_attachment_s3/static/description/index.html b/fs_attachment_s3/static/description/index.html index 8cad4ef01d..3443c3cb95 100644 --- a/fs_attachment_s3/static/description/index.html +++ b/fs_attachment_s3/static/description/index.html @@ -372,7 +372,7 @@

Fs Attachment S3

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:bf3d6979d1fa1dfe833a4b2663355ad392483c090177a137920f33ebb47ff224 +!! source digest: sha256:1ba96137af8042fcf51cd02e691f65ee0f3f9b910bb61aed0f341bf5f027b034 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/storage Translate me on Weblate Try me on Runboat

This module extends the functionality of @@ -390,18 +390,22 @@

Fs Attachment S3