diff --git a/fs_storage/models/fs_storage.py b/fs_storage/models/fs_storage.py index dd97710e5b..c36e48897c 100644 --- a/fs_storage/models/fs_storage.py +++ b/fs_storage/models/fs_storage.py @@ -182,6 +182,13 @@ def _server_env_fields(self): "eval_options_from_env": {}, } + 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 ac73b9bc4b..e6ccb40398 100644 --- a/fs_storage/readme/USAGE.md +++ b/fs_storage/readme/USAGE.md @@ -75,6 +75,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