-
-
Notifications
You must be signed in to change notification settings - Fork 354
Description
The following PR seems very useful #177
It would be nice to have a syntax like jsonify where you can specify for example for a res.partner:
_model_fields = ["country_number:country_id"]
You would get more flexibility in the datamodel fields that you declare and how to express it into an Odoo record.
More interestingly, in base_jsonify there is a syntax to run your input through a function :
_model_fields = [ ("country_code:country_id", "_format_country_code") ]
Then the flow expressed in the current syntax would look something like:
aCountry = _format_country_code(myInput.country_code) # searches the country by code and return id
delete myInput.country_code
myInput.country_id = aCountry
to_record(myInput)
That is the basic idea, it could probably become quite flexible if more fleshed-out.
I thought of this because for example on this module https://github.com/akretion/sale-import/blob/14.0/sale_import_base/components/importer_sale_channel.py we could make it very clean with such a feature