Skip to content

Commit ecb3bb7

Browse files
committed
[19.0][MIG] fs_folder
1 parent 5f660a6 commit ecb3bb7

10 files changed

Lines changed: 49 additions & 36 deletions

File tree

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ exclude: |
22
(?x)
33
# NOT INSTALLABLE ADDONS
44
^fs_file/|
5-
^fs_folder/|
65
^fs_folder_demo/|
76
^fs_folder_ms_drive/|
87
^fs_image/|

fs_folder/README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Fs Folder
2121
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
2222
:alt: License: LGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstorage-lightgray.png?logo=github
24-
:target: https://github.com/OCA/storage/tree/18.0/fs_folder
24+
:target: https://github.com/OCA/storage/tree/19.0/fs_folder
2525
:alt: OCA/storage
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/storage-18-0/storage-18-0-fs_folder
27+
:target: https://translation.odoo-community.org/projects/storage-19-0/storage-19-0-fs_folder
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/storage&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/storage&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -311,7 +311,7 @@ Bug Tracker
311311
Bugs are tracked on `GitHub Issues <https://github.com/OCA/storage/issues>`_.
312312
In case of trouble, please check there if your issue has already been reported.
313313
If you spotted it first, help us to smash it by providing a detailed and welcomed
314-
`feedback <https://github.com/OCA/storage/issues/new?body=module:%20fs_folder%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
314+
`feedback <https://github.com/OCA/storage/issues/new?body=module:%20fs_folder%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
315315

316316
Do not contact contributors directly about support or help with technical issues.
317317

@@ -358,6 +358,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
358358

359359
|maintainer-lmignon|
360360

361-
This module is part of the `OCA/storage <https://github.com/OCA/storage/tree/18.0/fs_folder>`_ project on GitHub.
361+
This module is part of the `OCA/storage <https://github.com/OCA/storage/tree/19.0/fs_folder>`_ project on GitHub.
362362

363363
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

fs_folder/__manifest__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
"name": "Fs Folder",
66
"summary": """A module to link to Odoo records and manage from record forms forlders
77
from external file systems """,
8-
"version": "18.0.1.0.0",
8+
"version": "19.0.1.0.0",
99
"license": "LGPL-3",
1010
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
1111
"website": "https://github.com/OCA/storage",
12-
"depends": [
13-
"fs_storage",
14-
],
12+
"depends": ["fs_storage", "bus"],
1513
"data": [
1614
"views/fs_storage.xml",
1715
],
@@ -21,6 +19,5 @@
2119
],
2220
},
2321
"demo": [],
24-
"installable": False,
2522
"maintainers": ["lmignon"],
2623
}

fs_folder/controllers/fs_folder_controller.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_file(self, res_id, res_model, field_name, path, download=False, **kwargs
2929

3030
@http.route(
3131
"/fs_folder/get_children/<string:res_model>/<int:res_id>/<string:field_name>",
32-
type="json",
32+
type="jsonrpc",
3333
auth="user",
3434
methods=["POST"],
3535
)
@@ -43,7 +43,7 @@ def get_children(self, res_id, res_model, field_name, path=""):
4343

4444
@http.route(
4545
"/fs_folder/add_folder/<string:res_model>/<int:res_id>/<string:field_name>",
46-
type="json",
46+
type="jsonrpc",
4747
auth="user",
4848
methods=["POST"],
4949
)
@@ -54,7 +54,7 @@ def add_folder(self, res_id, res_model, field_name, path, name):
5454

5555
@http.route(
5656
"/fs_folder/delete/<string:res_model>/<int:res_id>/<string:field_name>",
57-
type="json",
57+
type="jsonrpc",
5858
auth="user",
5959
methods=["POST"],
6060
)
@@ -65,7 +65,7 @@ def delete(self, res_id, res_model, field_name, path, name):
6565

6666
@http.route(
6767
"/fs_folder/move/<string:res_model>/<int:res_id>/<string:field_name>",
68-
type="json",
68+
type="jsonrpc",
6969
auth="user",
7070
methods=["POST"],
7171
)
@@ -83,7 +83,7 @@ def move_file(self, res_id, res_model, field_name, path, origin_path, record):
8383

8484
@http.route(
8585
"/fs_folder/copy/<string:res_model>/<int:res_id>/<string:field_name>",
86-
type="json",
86+
type="jsonrpc",
8787
auth="user",
8888
methods=["POST"],
8989
)
@@ -101,7 +101,7 @@ def copy_file(self, res_id, res_model, field_name, path, origin_path, record):
101101

102102
@http.route(
103103
"/fs_folder/rename/<string:res_model>/<int:res_id>/<string:field_name>",
104-
type="json",
104+
type="jsonrpc",
105105
auth="user",
106106
methods=["POST"],
107107
)
@@ -116,7 +116,7 @@ def rename(self, res_id, res_model, field_name, path, name, new_name):
116116

117117
@http.route(
118118
"/fs_folder/upload/<string:res_model>/<int:res_id>/<string:field_name>",
119-
type="json",
119+
type="jsonrpc",
120120
auth="user",
121121
methods=["POST"],
122122
)
@@ -132,7 +132,7 @@ def upload(self, res_id, res_model, field_name, path, name, data):
132132

133133
@http.route(
134134
"/fs_folder/initialize/<string:res_model>/<int:res_id>/<string:field_name>",
135-
type="json",
135+
type="jsonrpc",
136136
auth="user",
137137
methods=["POST"],
138138
)

fs_folder/fields.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
import fsspec
99

10-
from odoo import SUPERUSER_ID, api, fields, models, registry
10+
from odoo import SUPERUSER_ID, api, fields, models
11+
from odoo.modules.registry import Registry
1112
from odoo.tools.misc import SENTINEL, Sentinel
1213
from odoo.tools.sql import pg_varchar
1314

@@ -353,7 +354,7 @@ def create_value_in_fs(self, records: models.BaseModel) -> list[FsFolderValue]:
353354
fs.mkdir(path, **kwargs)
354355

355356
def clean_up_folder(path, storage_code, dbname):
356-
db_registry = registry(dbname)
357+
db_registry = Registry(dbname)
357358
with db_registry.cursor() as cr:
358359
env = api.Environment(cr, SUPERUSER_ID, {})
359360
fs = env["fs.storage"].get_fs_by_code(storage_code)

fs_folder/models/fs_folder_field_web_api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import fsspec
88
from werkzeug import Response
99

10-
from odoo import _, api, models
10+
from odoo import api, models
1111
from odoo.exceptions import AccessError
1212

1313
from ..fs_stream import FsStream
@@ -31,10 +31,10 @@ def _check_field_access(self, res_id, res_model, field_name, access):
3131
:param access: the access rights to check
3232
"""
3333
if res_model not in self.env:
34-
raise AccessError(_("Unknown model"))
34+
raise AccessError(self.env._("Unknown model"))
3535
record = self.env[res_model].browse(res_id)
3636
if field_name not in record._fields:
37-
raise AccessError(_("Unknown field"))
37+
raise AccessError(self.env._("Unknown field"))
3838
record.check_access(access)
3939

4040
@api.model
@@ -76,7 +76,9 @@ def _get_fs(
7676
if field.type == "fs_folder":
7777
fs = record[field_name].fs
7878
if not fs:
79-
raise ValueError(_("The field is not an external filesystem field."))
79+
raise ValueError(
80+
self.env._("The field is not an external filesystem field.")
81+
)
8082
return fs
8183

8284
@api.model

fs_folder/models/fs_storage.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
33
import re
44

5-
from odoo import _, api, fields, models, tools
5+
from odoo import api, fields, models, tools
66
from odoo.exceptions import UserError, ValidationError
77

88

@@ -33,18 +33,23 @@ def _check_fs_name_sanitization_replace_char(self):
3333

3434
if rc and self._invalid_fs_name_chars_re_pattern.findall(rc):
3535
raise ValidationError(
36-
_("The character to use as replacement can not be one of '%s'")
37-
% self._invalid_fs_name_chars
36+
self.env._(
37+
"The character to use as replacement can not be one of "
38+
"'%(invalid_chars)s'",
39+
invalid_chars=self._invalid_fs_name_chars,
40+
)
3841
)
3942

4043
@api.constrains("use_as_default_for_fs_contents")
4144
def _check_use_as_default_for_fs_contents(self):
4245
# constrains are checked in python since values can be provided by
4346
# the server environment
44-
defaults = self.search([]).filtered("use_as_default_for_fs_contents")
47+
defaults = self.search([]).filtered("use_as_default_for_fs_contents") # pylint: disable=no-search-all
4548
if len(defaults) > 1:
4649
raise ValidationError(
47-
_("Only one storage can be used as default for filesystem contents.")
50+
self.env._(
51+
"Only one storage can be used as default for filesystem contents."
52+
)
4853
)
4954

5055
@property
@@ -60,6 +65,7 @@ def _server_env_fields(self):
6065
@api.model
6166
@tools.ormcache()
6267
def get_storage_code_for_fs_content_fallback(self) -> str | None:
68+
# pylint: disable=no-search-all
6369
storages = (
6470
self.sudo()
6571
.search([])
@@ -80,7 +86,7 @@ def get_default_storage_code_for_fs_content(self, model_name, field_name) -> str
8086
storage_code = self.get_storage_code_for_fs_content_fallback()
8187
if not storage_code:
8288
raise ValueError(
83-
_(
89+
self.env._(
8490
"No default storage found for the content of the external "
8591
"filesystem fields for model %(model)s and field %(field)s. "
8692
"Please set a default storage in the filesystem storage "
@@ -105,7 +111,7 @@ def is_fs_name_valid(self, name, raise_if_invalid=False) -> bool:
105111
invalid = self._invalid_fs_name_chars_re_pattern.findall(name)
106112
if invalid and raise_if_invalid:
107113
raise UserError(
108-
_(
114+
self.env._(
109115
"The name '%(name)s' contains invalid characters"
110116
" %(invalid_chars)s.\n"
111117
"The following chars are not allowed: %(all_invalid_chars)s",

fs_folder/static/description/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ <h1>Fs Folder</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:c4cce3679f458dfca0f84f2626680d41bd9ae5049b0fde289ecb07ee4359a869
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/storage/tree/18.0/fs_folder"><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-18-0/storage-18-0-fs_folder"><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=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/storage/tree/19.0/fs_folder"><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-19-0/storage-19-0-fs_folder"><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=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>If you need to link some specific models to a specific folder into an
379379
external filesystem and be able to manage the content of this folder
380380
from the model form view, this module is for you.</p>
@@ -645,7 +645,7 @@ <h2><a class="toc-backref" href="#toc-entry-11">Bug Tracker</a></h2>
645645
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/storage/issues">GitHub Issues</a>.
646646
In case of trouble, please check there if your issue has already been reported.
647647
If you spotted it first, help us to smash it by providing a detailed and welcomed
648-
<a class="reference external" href="https://github.com/OCA/storage/issues/new?body=module:%20fs_folder%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
648+
<a class="reference external" href="https://github.com/OCA/storage/issues/new?body=module:%20fs_folder%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
649649
<p>Do not contact contributors directly about support or help with technical issues.</p>
650650
</div>
651651
<div class="section" id="credits">
@@ -682,7 +682,7 @@ <h3><a class="toc-backref" href="#toc-entry-16">Maintainers</a></h3>
682682
promote its widespread use.</p>
683683
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
684684
<p><a class="reference external image-reference" href="https://github.com/lmignon"><img alt="lmignon" src="https://github.com/lmignon.png?size=40px" /></a></p>
685-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/storage/tree/18.0/fs_folder">OCA/storage</a> project on GitHub.</p>
685+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/storage/tree/19.0/fs_folder">OCA/storage</a> project on GitHub.</p>
686686
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
687687
</div>
688688
</div>

fs_folder/tests/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def setUpClass(cls):
2323
cls.loader.update_registry(
2424
(FsTestModel, FsTestModelInherits, FsTestModelRelated)
2525
)
26+
2627
cls.fs_test_model = cls.env[FsTestModel._name]
2728
cls.fs_test_model_inherits = cls.env[FsTestModelInherits._name]
2829
cls.fs_test_model_related = cls.env[FsTestModelRelated._name]

fs_folder/tests/test_fs_storage.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@
55
from odoo.tests.common import TransactionCase
66

77
from odoo.addons.base.tests.common import BaseCommon
8+
from odoo.addons.fs_storage.models.fs_storage import FSStorage
89

910

1011
class TestFsStorage(TransactionCase):
1112
@classmethod
1213
def setUpClass(cls):
1314
super().setUpClass()
1415
cls.env = cls.env["base"].with_context(**BaseCommon.default_env_context()).env
15-
cls.backend = cls.env.ref("fs_storage.fs_storage_demo")
16+
cls.backend: FSStorage = cls.env["fs.storage"].create(
17+
{
18+
"name": "Odoo Filesystem Backend",
19+
"protocol": "odoofs",
20+
"code": "odoofs",
21+
}
22+
)
1623

1724
def test_is_fs_name_valid(self):
1825
self.assertFalse(self.backend.is_fs_name_valid(r'my\/:*?"<>| directory'))

0 commit comments

Comments
 (0)