diff --git a/fs_storage/models/fs_storage.py b/fs_storage/models/fs_storage.py index b811e59d84..0446a85ecd 100644 --- a/fs_storage/models/fs_storage.py +++ b/fs_storage/models/fs_storage.py @@ -162,6 +162,13 @@ def __init__(self, env, ids=(), prefetch_ids=()): 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) + # replace {db_name} with the dbname + if field_name == "directory_path": + value = value.format(db_name=self.env.cr.dbname) + return value + def write(self, vals): self.__fs = None self.env.registry.clear_cache() diff --git a/fs_storage/readme/USAGE.md b/fs_storage/readme/USAGE.md index 2379e3b398..851f5ae103 100644 --- a/fs_storage/readme/USAGE.md +++ b/fs_storage/readme/USAGE.md @@ -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. diff --git a/fs_storage/readme/newsfragments/db_name.feature b/fs_storage/readme/newsfragments/db_name.feature new file mode 100644 index 0000000000..81960069cc --- /dev/null +++ b/fs_storage/readme/newsfragments/db_name.feature @@ -0,0 +1 @@ +Replace {db_name} by the database name in directory_path