Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][IMP] fs_storage: replace {db_name} in directory_path #379

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions fs_storage/models/fs_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@
def _server_env_fields(self):
return {"protocol": {}, "options": {}, "directory_path": {}}

def _server_env_read_from_config(self, field_name, config_getter):
value = super()._server_env_read_from_config(field_name, config_getter)

Check warning on line 166 in fs_storage/models/fs_storage.py

View check run for this annotation

Codecov / codecov/patch

fs_storage/models/fs_storage.py#L166

Added line #L166 was not covered by tests
# replace {db_name} with the dbname
if field_name == "directory_path":
value = value.format(db_name=self.env.cr.dbname)
return value

Check warning on line 170 in fs_storage/models/fs_storage.py

View check run for this annotation

Codecov / codecov/patch

fs_storage/models/fs_storage.py#L169-L170

Added lines #L169 - L170 were not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also probably not the best place to implement this, as if we do this, it should not behave differently when the value is entered manually or via server environment.


def write(self, vals):
self.__fs = None
self.env.registry.clear_cache()
Expand Down
2 changes: 2 additions & 0 deletions fs_storage/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ for the following fields:
- options
- directory_path

When evaluating directory_path, `{db_name}` is replaced by the database name.

## Migration from storage_backend

The fs_storage addon can be used to replace the storage_backend addon.
Expand Down
1 change: 1 addition & 0 deletions fs_storage/readme/newsfragments/db_name.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace {db_name} by the database name in directory_path
Loading