Hi, everyone:
I'm using restful API to create record, like this:
@route('/api/v2/<string:model>', auth='user',
methods=["POST"], csrf=False)
@make_response()
def create(self, model, **kwargs):
eval_request_params(kwargs)
obj = request.env[model].create(**kwargs)
return obj.id
The question is:
the API pass the model's required field validation, just create a new record. (It should return a exception and tells the field is required, don't allow to create)
How to let "request.env[model].create(**kwargs)" know the model's required setting?
The question is:
the API pass the model's required field validation, just create a new record. (It should return a exception and tells the field is required, don't allow to create)
How to let "request.env[model].create(**kwargs)" know the model's required setting?
Hi, I'm not sure if you are looking for this:
request.env['ir.model.fields'].search([('model', '=', 'your.model'), ('required', '=', True)])
This will return all required fields in 'your.model'