Storage File
storage_file · OCA/storage
-
Security25/25No findings
-
Activity25/25Last human commit 2 months ago
-
Required by20/252 modules depend on it
-
Maturity25/25In 9 Odoo series since 10.0
Heuristic over the facts below, not an audit · How it's computed
Migration considerations
StorageFile— Since 19.0: `_sql_constraints` is ignored and its constraints are silently not created: declare `models.Constraint` attributes instead. migration-sql-constraints · source
Migration review checklist, not a compatibility verdict. "Migrating to X.0" applies once you upgrade to that version; "Since X.0" means this version already ignores or rejects that code. Methodology
Description
External file management depending on Storage Backend module.
It include these features: * link to any Odoo model/record * store metadata like: checksum, mimetype
Use cases (with help of additional modules): - store pdf (like invoices) on a file server with high SLA - access attachments with read/write on prod environment and only read only on dev / testing
Dependencies
- Odoo dependencies
- Python dependencies
- python_slugify
- System dependencies
- None
- Required by
- storage_media, storage_thumbnail
Code analysis
Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.
Views touched 4
| XML ID | Name | Model | Type | Status |
|---|---|---|---|---|
storage_backend_view_form |
storage.backend | form | Inherits storage_backend.storage_backend_view_form | |
storage_file_view_form |
storage.file | form | New | |
storage_file_view_search |
storage.file | search | New | |
storage_file_view_tree |
storage.file | list | New |
HTTP endpoints 1
| Route(s) | Handler | Auth | Type | Methods | Flags |
|---|---|---|---|---|---|
/storage.file/<string:slug_name_with_id> |
StorageFileController.content_common |
public | http | ALL |
Models touched 4
No new fields.
Public methods (1)-
render_qweb_pdf(self, res_ids=None, data=None)
-
backend_view_use_internal_urlBooleanhelp='Decide if Odoo backend views should use the external URL (usually a CDN) or the internal url with direct access to the storage. This could save you some money if you pay by CDN traffic.' -
base_urlChardefault='' -
base_url_for_filesCharcompute='_compute_base_url_for_files'store=True -
filename_strategySelectiondefault='name_with_id'help='Strategy to build the name of the file to be stored.\nName and ID: will store the file with its name + its id.\nSHA Hash: will use the hash of the file as filename (same method as the native attachment storage)'selection=[('name_with_id', 'Name and ID'), ('hash', 'SHA hash')] -
is_publicBooleandefault=Falsehelp='Define if every files stored into this backend are public or not. Examples:\nPrivate: your file/image can not be displayed is the user is not logged (not available on other website);\nPublic: your file/image can be displayed if nobody is logged (useful to display files on external websites)' -
served_bySelectiondefault='odoo'required=Trueselection=[('odoo', 'Odoo'), ('external', 'External')] -
url_include_directory_pathBooleandefault=Falsehelp="Normally the directory_path it's for internal usage. If this flag is enabled the path will be used to compute the public URL."
-
action_recompute_base_url_for_files(self)Refresh base URL for files. Rationale: all the params for computing this URL might come from server env. When this is the case, the URL - being stored - might be out of date. This is because changes to server env fields are not detected at startup. Hence, let's offer an easy way to promptly force this manually when needed. -
write(self, vals)
-
activeBooleandefault=True -
backend_idMany2one → storage.backendindex=Truerequired=True args: 'storage.backend', 'Storage' -
checksumCharindex=Truesize=40 args: 'Checksum/SHA1' -
company_idMany2one → res.companydefault=<expr> args: 'res.company', 'Company' -
dataBinarycompute='_compute_data'copy=Truehelp='Data'inverse='_inverse_data'store=False -
extensionCharcompute='_compute_extract_filename'store=True -
file_sizeInteger -
file_typeSelectionargs: [] -
filenameCharcompute='_compute_extract_filename'store=True args: 'Filename without extension' -
human_file_sizeCharcompute='_compute_human_file_size'store=True -
internal_urlCharcompute='_compute_internal_url'help='HTTP URL to load the file directly from storage.' -
mimetypeCharcompute='_compute_extract_filename'store=True args: 'Mime Type' -
nameCharindex=Truerequired=True -
relative_pathCharcopy=Falsehelp='Relative location for backend' -
slugCharcompute='_compute_slug'help='Slug-ified name with ID for URL'store=True -
to_deleteBoolean -
urlCharcompute='_compute_url'help='HTTP accessible path to the file' -
url_pathCharcompute='_compute_url_path'help='Accessible path, no base URL'
-
get_from_slug_name_with_id(self, slug_name_with_id)@api.modelReturn a browse record from a string generated by the method _slugify_name_with_id :param slug_name_with_id: :return: a BrowseRecord (could be empty...) -
unlink(self) -
write(self, vals)
-
dataBinary -
file_idMany2one → storage.fileargs: 'storage.file' -
file_nameChar
-
confirm(self)
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…