uploadkit-odoo
Odoo integration for UploadKit.
What problem does this solve?
Adapts Werkzeug/FileStorage uploads from Odoo controllers and maps UploadKit exceptions to JSON responses — without reimplementing validation or storage. An optional Odoo 17/18 addon wires settings and a thin upload service/HTTP route.
When to use it
Use when an Odoo app uploads files through UploadKit Core (controllers or the uploadkit.service model).
When not to use it
Do not put validators, policies, or storage implementations in this package. Supply your own StorageProvider (e.g. boto3 → AWS S3 or MinIO). Creating ir.attachment records after upload is left to your module.
Installation
Requires Python 3.10–3.12 (Odoo 17/18 host range) and Odoo 17 or 18 for the addon.
pip install uploadkit-odoo uploadkit-security
uv add uploadkit-odoo uploadkit-security
poetry add uploadkit-odoo uploadkit-security
For S3/MinIO samples: pip install boto3.
Python × Odoo support
| Python | Odoo |
|---|---|
| 3.10–3.12 | Odoo 17, Odoo 18 |
Python 3.13+ will be added once Odoo officially supports it.
Licenses
- PyPI package (
uploadkit-odoo): Apache-2.0 - Odoo addon (
addons/uploadkit_odoo): LGPL-3
Library quick start (controller)
from odoo import http
from odoo.http import request
from uploadkit import Uploader, UploadPolicy, UploaderError
from uploadkit_odoo import as_uploadable, json_error_response
from uploadkit_security import default_validators
def notify(result):
...
class MyController(http.Controller):
@http.route("/my/upload", type="http", auth="user", methods=["POST"], csrf=True)
def upload(self, **kw):
storage = get_provider() # your StorageProvider factory
policy = UploadPolicy(
max_size=5 * 1024 * 1024,
allowed_extensions=frozenset({"png"}),
allowed_mime_types=frozenset({"image/png"}),
validators=default_validators(),
)
uploaded = kw.get("file")
try:
result = Uploader(policy, storage).upload(
as_uploadable(uploaded),
bucket="uploads",
object_name=uploaded.filename,
after_upload=notify, # or a Celery-like task with .delay
)
except UploaderError as exc:
return json_error_response(exc)
return request.make_json_response(result.as_task_kwargs())
After-upload
Library controllers can pass Core after_upload on Uploader.upload (sync callback or Celery-like .delay). The optional addon uploadkit.service.upload() returns UploadResult.as_task_kwargs() and does not accept a hook — call Core Uploader directly (as above), or enqueue work from the returned dict. Full semantics: uploadkit Core README.
Storage provider (AWS S3 or MinIO)
Same class for both backends — omit endpoint_url for AWS, set it for MinIO:
# my_module/storage.py
import boto3
from botocore.client import Config
from odoo.tools import config
class Boto3S3Storage:
def __init__(
self,
*,
access_key: str,
secret_key: str,
region: str = "us-east-1",
endpoint_url: str | None = None,
) -> None:
kwargs: dict = {
"service_name": "s3",
"aws_access_key_id": access_key,
"aws_secret_access_key": secret_key,
"region_name": region,
"config": Config(signature_version="s3v4"),
}
if endpoint_url:
kwargs["endpoint_url"] = endpoint_url
self.client = boto3.client(**kwargs)
def put(self, *, bucket, object_name, body, content_type):
resp = self.client.put_object(
Bucket=bucket,
Key=object_name,
Body=body,
ContentType=content_type,
)
return resp.get("ETag")
def get_provider():
"""Factory used by uploadkit.storage_provider config parameter."""
return Boto3S3Storage(
access_key=config.get("uploadkit_access_key", ""),
secret_key=config.get("uploadkit_secret_key", ""),
region=config.get("uploadkit_region", "us-east-1"),
endpoint_url=config.get("uploadkit_endpoint_url") or None,
)
Odoo addon
- Add this repo’s
addons/directory to Odooaddons_path. pip install uploadkit-odoo uploadkit-security(and your storage deps).- Install UploadKit in Apps.
- Configure under Settings → UploadKit:
- Storage provider factory (dotted path, e.g.
my_module.storage.get_provider) - Upload bucket
- Optional object name prefix and max size
- Storage provider factory (dotted path, e.g.
Service API
result = env["uploadkit.service"].upload(file_storage, object_name="docs/a.pdf")
# result is UploadResult.as_task_kwargs() — no after_upload parameter
# Enqueue from the dict, or call Uploader.upload(..., after_upload=...) yourself
HTTP route
POST /uploadkit/upload (auth=user, CSRF) with multipart field file (optional object_name). Returns JSON success payload or the standard UploadKit error shape.
After a successful upload you may create an ir.attachment yourself (e.g. type='url' pointing at your object URL). This package does not store into ir.attachment.
Architecture
Thin adapters over UploadKit Core. Odoo multipart uploads are Werkzeug FileStorage; as_uploadable wraps them for Uploader.
Public API (library)
| Symbol | Kind |
|---|---|
as_uploadable |
Public |
json_error_response / status_for_error / error_payload |
Public |
Changelog
See CHANGELOG.md.
Contributing
See CONTRIBUTING.md.
Metadata
Release files for uploadkit-odoo 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| uploadkit_odoo-0.1.1.tar.gz | 15.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| uploadkit_odoo-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.2 kB
Release files / uploadkit_odoo-0.1.1.tar.gz
| Download URL | uploadkit_odoo-0.1.1.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ab05846ee123611b591662828197147ee3ee34ab57f477032049ff28276a54b
|
|
BLAKE2b-256 checksum How to use checksums |
16799df0652a40292fad2204edc872a73d2c2edaba128a3b49efad4653d73458
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / uploadkit_odoo-0.1.1-py3-none-any.whl
| Download URL | uploadkit_odoo-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46cd0ae265385a30748624ad490dad6e75617437360ec0e20a436e1807d1c1c5
|
|
BLAKE2b-256 checksum How to use checksums |
e6bfe66dc6d2af65d0ee7ccc6c36213d1a27df560222662ec724a30cd71f806e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for uploadkit-odoo 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.