-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convention converting a pydantic model to odoo vals #1427
Comments
@sebastienbeau It depends. When a Pydantic model is 'linked' to an odoo model, A method Regarding, your complex version, IMO it's too complex. You could have a 'convert_to_my_model_write' method defined on your pydantic model. At least, don't use the result of a call to |
Thanks for your feedback. |
I have done some change in my PR. Here is how to convert "input params" into domain : Here is how I have converted "input params" to vals for the write |
Hi @shopinvader/shopinvader-maintainers
I would like you thoughts, regarding the best and cleanest way to convert a pydantic model into a dict of vals for odoo.
I see that two way have been used.
Converting the pydantic object into a vals into the pydantic class it's self
See here :
odoo-shopinvader/shopinvader_api_address/schemas.py
Lines 23 to 35 in 10a15b4
Or in the "service"
See here (complex conversion) :
odoo-shopinvader/shopinvader_api_cart/routers/cart.py
Line 211 in 10a15b4
See here : https://github.com/shopinvader/odoo-shopinvader/pull/1421/files#diff-2bc91465c2d564fb6b38ffc94e181249d747a657a72b732b7a535902dab66e5aR240
@lmignon what do you think ?
The text was updated successfully, but these errors were encountered: