Skip to content

Conversation

@fdegrave
Copy link

@fdegrave fdegrave commented Jul 2, 2021

This model adds functionalities similar to (a subset of) what offers Django Rest Framework through their Model Serializers (hence the name).

The ModelSerializer class inherits from the Datamodel class and adds functionalities. Therefore any class inheriting from ModelSerializer can be used the exact same way as any other Datamodel.

Basic example:

    from odoo.addons.model_serializer.core import ModelSerializer

    class PartnerInfo(ModelSerializer):
        _name = "partner.info"
        _model = "res.partner"
        _model_fields = ["id", "name", "country_id"]

This ModelSerializer also provides methods to easily transform a recordset into a corresponding datamodel, and vice-versa. Please read the (still very short) doc to have more info on how it works.

I know there are no tests yet, but I will add them in case that the module is accepted. Test added! Not full yet, but quite complete

@fdegrave fdegrave mentioned this pull request Jul 2, 2021
@fdegrave fdegrave changed the title [ADD] model_serializer: module to facilitate the (de)serialization of Odoo Models into DataModels [13.0][ADD] model_serializer: module to facilitate the (de)serialization of Odoo Models into DataModels Jul 2, 2021
@fdegrave fdegrave force-pushed the 13.0-model-serializer branch from bcdc8e7 to 6d19777 Compare July 28, 2021 14:46
@fdegrave fdegrave force-pushed the 13.0-model-serializer branch from 6d19777 to 0917c36 Compare August 25, 2021 12:23
fdegrave pushed a commit to fdegrave/rest-framework that referenced this pull request Sep 2, 2021
…ion of Odoo Models into DataModels

Forward port of PR OCA#177
@lmignon
Copy link
Contributor

lmignon commented Nov 9, 2021

same as in #193

@lmignon
Copy link
Contributor

lmignon commented Nov 9, 2021

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 13.0-ocabot-merge-pr-177-by-lmignon-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 6acd42c into OCA:13.0 Nov 9, 2021
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 269746e. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants