diff --git a/fs_attachment/models/fs_storage.py b/fs_attachment/models/fs_storage.py index d1bf83258c..2554c1001c 100644 --- a/fs_attachment/models/fs_storage.py +++ b/fs_attachment/models/fs_storage.py @@ -1,6 +1,8 @@ # Copyright 2023 ACSONE SA/NV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from __future__ import annotations + from odoo import _, api, fields, models, tools from odoo.exceptions import ValidationError from odoo.tools.safe_eval import const_eval @@ -348,7 +350,11 @@ def get_force_db_for_default_attachment_rules(self, code): 0 means no limit. """ storage = self.get_by_code(code) - if storage and storage.force_db_for_default_attachment_rules: + if ( + storage + and storage.use_as_default_for_attachments + and storage.force_db_for_default_attachment_rules + ): return const_eval(storage.force_db_for_default_attachment_rules) return {} diff --git a/fs_attachment/models/ir_attachment.py b/fs_attachment/models/ir_attachment.py index fd4a2a0e48..8b34a6b9c3 100644 --- a/fs_attachment/models/ir_attachment.py +++ b/fs_attachment/models/ir_attachment.py @@ -2,6 +2,8 @@ # Copyright 2023 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) +from __future__ import annotations + import io import logging import mimetypes diff --git a/fs_attachment/readme/CONTRIBUTORS.rst b/fs_attachment/readme/CONTRIBUTORS.rst index b06e37ea72..886c390695 100644 --- a/fs_attachment/readme/CONTRIBUTORS.rst +++ b/fs_attachment/readme/CONTRIBUTORS.rst @@ -10,3 +10,4 @@ Don Kendall Stephane Mangin Laurent Mignon Marie Lejeune +Wolfgang Pichler diff --git a/fs_attachment/readme/newsfragments/.gitignore b/fs_attachment/readme/newsfragments/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/fs_attachment/readme/newsfragments/285.bugfix b/fs_attachment/readme/newsfragments/285.bugfix new file mode 100644 index 0000000000..ad218e3faa --- /dev/null +++ b/fs_attachment/readme/newsfragments/285.bugfix @@ -0,0 +1 @@ +Ensures python 3.9 compatibility. diff --git a/fs_attachment/readme/newsfragments/286.bugfix b/fs_attachment/readme/newsfragments/286.bugfix new file mode 100644 index 0000000000..936f148ae1 --- /dev/null +++ b/fs_attachment/readme/newsfragments/286.bugfix @@ -0,0 +1,2 @@ +If a storage is not used to store all the attachments by default, the call to the +`get_force_db_for_default_attachment_rules` method must return an empty dictionary. diff --git a/fs_storage/models/fs_storage.py b/fs_storage/models/fs_storage.py index 5bcc5f3e5e..b1886b7f77 100644 --- a/fs_storage/models/fs_storage.py +++ b/fs_storage/models/fs_storage.py @@ -314,6 +314,13 @@ def _get_filesystem(self) -> fsspec.AbstractFileSystem: options = self.json_options if self.protocol == "odoofs": options["odoo_storage_path"] = self._odoo_storage_path + # Webdav protocol handler does need the auth to be a tuple not a list ! + if ( + self.protocol == "webdav" + and "auth" in options + and isinstance(options["auth"], list) + ): + options["auth"] = tuple(options["auth"]) options = self._recursive_add_odoo_storage_path(options) fs = fsspec.filesystem(self.protocol, **options) directory_path = self.directory_path diff --git a/fs_storage/readme/newsfragments/.gitignore b/fs_storage/readme/newsfragments/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/fs_storage/readme/newsfragments/285.bugfix b/fs_storage/readme/newsfragments/285.bugfix new file mode 100644 index 0000000000..75a7e27c5a --- /dev/null +++ b/fs_storage/readme/newsfragments/285.bugfix @@ -0,0 +1,4 @@ +Avoid config error when using the webdav protocol. The auth option is expected +to be a tuple not a list. Since our config is loaded from a json file, we +cannot use tuples. The fix converts the list to a tuple when the config is +related to a webdav protocol and the auth option is into the confix.