def get(self, model=None, id=None, **payload): ioc_name = model model = request.env[self._model].sudo().search([("model", "=", model)], limit=1) if model: domain, fields, offset, limit, order = extract_arguments(payload) data = (request.env[model.model].sudo().search_read( domain=domain, fields=fields, offset=offset, limit=limit, order=order, )) if id: domain = [("id", "=", int(id))] data = (request.env[model.model].sudo().search_read( domain=domain, fields=fields, offset=offset, limit=limit, order=order, )) if data: return valid_response(data) else: return valid_response(data) return invalid_response( "invalid object model", "The model %s is not available in the registry." % ioc_name, )
def get(self, model=None, id=None, **payload): ioc_name = model model = request.env[self._model].sudo().search([('model', '=', model)], limit=1) if model: domain, fields, offset, limit, order = extract_arguments(payload) data = request.env[model.model].sudo().search_read(domain=domain, fields=fields, offset=offset, limit=limit, order=order) if data: return valid_response(data) else: return valid_response(data) return invalid_response( 'invalid object model', 'The model %s is not available in the registry.' % ioc_name)