Base Rest Base Structure
This addon aims to provide a basic service and controller structure to simplify a rest custom implemenation in other odoo modules.
Usage
On our custom module. When we need to expose an specific model we’ll create a service extending from the base ones.
from odoo.addons.component.core import Component
from odoo.addons.base_rest_base_structure.models.api_services_utils import APIServicesUtils
class CustomModelService(Component):
_inherit = "base.rest.private_abstract_service"
_name = "custom_module.custom_model.services"
_usage = "custom-endpoint"
_description = """
Custom Model Service
"""
def get(self, _id):
record = self.env["custom_module.custom_model"].search(
[("id", "=", _id)]
)
if record:
record.ensure_one()
utils = APIServicesUtils.get_instance()
# Define here all fields to be passed to the response
attributes = ["name"]
# Define here all many2one fields to be passed to the response
rel_attributes = {
"rel_model_id" : "name"
}
return utils.generate_get_dictionary(record,attributes,rel_attributes)
else:
raise wrapJsonException(
NotFound(_("No reward record for id %s") % _id)
)
def create(self, **params):
utils = APIServicesUtils.get_instance()
# define all fields that the API receive
attributes = ["name"]
create_dict = utils.generate_create_dictionary(params,attributes)
record = self.env["custom_module.custom_model"].create(create_dict)
return {"_id": record.id}
# rest of methods defined below
Changelog
12.0.1.0.0
First official version.
Bug Tracker
Bugs are tracked on GitLab Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.
Credits
Based on the initial work of Robin Keunen <robin@coopiteasy.be> for easy_my_coop_api module and on base_rest_demo from OCA rest-api. Trying to decople this functionallity from easy_my_coop vertical-cooperative infraestructure.
Contributors
Dani Quilez <dani.quilez@coopdevs.org>
Maintainers
This module is maintained by Coopdevs Treball SCCL.
Metadata
Release files for odoo12-addon-base-rest-base-structure 12.0.1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| odoo12_addon_base_rest_base_structure-12.0.1.0.3-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for odoo12_addon_base_rest_base_structure-12.0.1.0.3-py2.py3-none-any.whl |
Release files / odoo12_addon_base_rest_base_structure-12.0.1.0.3-py2.py3-none-any.whl
| Download URL | odoo12_addon_base_rest_base_structure-12.0.1.0.3-py2.py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
8cd7c3831211288a8b94a6342267ad7865f29ca3ddf97b51425e267533bb71c1
|
|
BLAKE2b-256 checksum How to use checksums |
1b9abf11fb35aea03b695918dfe14a8c55c45a2e077392885945d2a6fe399ce8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2
|
Security for odoo12-addon-base-rest-base-structure 12.0.1.0.3
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.