Skip to content
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
8 changes: 7 additions & 1 deletion fs_attachment/models/fs_storage.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 {}

Expand Down
2 changes: 2 additions & 0 deletions fs_attachment/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions fs_attachment/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Don Kendall <kendall@donkendall.com>
Stephane Mangin <stephane.mangin@camptocamp.com>
Laurent Mignon <laurent.mignon@acsone.eu>
Marie Lejeune <marie.lejeune@acsone.eu>
Wolfgang Pichler <wpichler@callino.at>
Empty file.
1 change: 1 addition & 0 deletions fs_attachment/readme/newsfragments/285.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensures python 3.9 compatibility.
2 changes: 2 additions & 0 deletions fs_attachment/readme/newsfragments/286.bugfix
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions fs_storage/models/fs_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file.
4 changes: 4 additions & 0 deletions fs_storage/readme/newsfragments/285.bugfix
Original file line number Diff line number Diff line change
@@ -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.