# ir.model

Provides information about Odoo models via its various fields

**name**

a human-readable description of the model

**model**

the name of each model in the system

**state**

whether the model was generated in Python code (<mark style="color:orange;">`base`</mark>) or by creating an <mark style="color:orange;">`ir.model`</mark> record (<mark style="color:orange;">`manual`</mark>)

**field\_id**

list of the model’s fields through a [One2many](https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html#odoo.fields.One2many) to [ir.model.fields](/rest-api/inspection-and-introspection/ir.model.fields.md)

**view\_ids**

[One2many](https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html#odoo.fields.One2many) to the [Views](https://www.odoo.com/documentation/16.0/developer/reference/backend/views.html) defined for the model

**access\_ids**

[One2many](https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html#odoo.fields.One2many) relation to the [Access Control](https://www.odoo.com/documentation/16.0/developer/reference/backend/security.html#access-rights) set on the model

<mark style="background-color:blue;">**Note**</mark>

<mark style="background-color:blue;">`ir.model`</mark> <mark style="background-color:blue;"></mark><mark style="background-color:blue;">can be used to:</mark>

* <mark style="background-color:blue;">query the system for installed models (as a precondition to operations on the model or to explore the system’s content)</mark>
* <mark style="background-color:blue;">get information about a specific model (generally by listing the fields associated with it)</mark>
* <mark style="background-color:blue;">create new models dynamically over REST API</mark>

<mark style="background-color:orange;">**Warning**</mark>

* <mark style="background-color:orange;">**custom**</mark> <mark style="background-color:orange;"></mark><mark style="background-color:orange;">model names must start with</mark> <mark style="background-color:orange;"></mark><mark style="background-color:orange;">`x_`</mark>
* <mark style="background-color:orange;">the</mark> <mark style="background-color:orange;"></mark><mark style="background-color:orange;">`state`</mark> <mark style="background-color:orange;"></mark><mark style="background-color:orange;">must be provided and</mark> <mark style="background-color:orange;"></mark><mark style="background-color:orange;">`manual`</mark><mark style="background-color:orange;">, otherwise, the model will not be loaded</mark>
* <mark style="background-color:orange;">it is not possible to add new</mark> <mark style="background-color:orange;"></mark>*<mark style="background-color:orange;">methods</mark>* <mark style="background-color:orange;"></mark><mark style="background-color:orange;">to a custom model, only fields</mark><br>

**Example**

Create <mark style="color:orange;">`x_custom_model`</mark> model record in <mark style="color:orange;">`ir.model`</mark> object using [Create Records](/rest-api/calling-methods/create-records.md) API endpoint.

**Request:**

```
POST /restapi/1.0/object/ir.model?vals={'name':'Custom Model','model':'x_custom_model','state':'manual'} HTTP/1.1
Host: {your_Odoo_server_url}

```

**JSON Response**:

```
HTTP/1.1 200 OK

{
  'Models': {
      'id': 104,
      'name': 'Custom Model',
      'model': 'x_custom_model',
      'state': 'manual'
      ...
      ...
      ...
  }
}
```

**XML Response:**

```
HTTP/1.1 200 OK

<Models type="dict">
	<id type="int">104</id>
	<name type="str">Custom Model</name>
	<model type="str">x_custom_model</model>
	<state type="str">manual</state>
</Models>
```

2. Inspect a model <mark style="color:orange;">`x_custom_model`</mark>’s fields using the [Listing Record Fields](/rest-api/calling-methods/listing-record-fields.md) API endpoint.

**Request:**

```
GET /restapi/1.0/object/x_custom_model/fields_get?attributes=['string','help','type'] HTTP/1.1
Host: {your_Odoo_server_url}
```

**JSON Response:**

<mark style="background-color:blue;">**Note**</mark>

<mark style="background-color:blue;">a custom model will initially contain only the “built-in” fields available on all models</mark>

```
 HTTP/1.1 200 OK

 {
   'fields': {
       'create_uid': {
           'type': 'many2one',
           'string': 'Created by'
       },
       'create_date': {
           'type": 'datetime',
           'string': 'Created on'
       },
       '__last_update': {
           'type': 'datetime',
           'string': 'Last Modified on'
       },
       'write_uid': {
           'type': 'many2one',
           'string': 'Last Updated by'
       },
       'write_date': {
           'type': 'datetime',
           'string': 'Last Updated on'
       },
       'display_name': {
           'type': 'char',
           'string': 'Display Name'
       },
       'id": {
           'type': 'integer',
           'string': 'Id'
       }
   }
}
```

**XML Response:**

```
HTTP/1.1 200 OK

<fields type="dict">
	<create_uid type="dict">
		<type type="str">many2one</type>
		<string type="str">Created by</string>
	</create_uid>
	<create_date type="dict">
		<type type="str">datetime</type>
		<string type="str">Created on</string>
	</create_date>
	<__last_update type="dict">
		<type type="str">datetime</type>
		<string type="str">Last Modified on</string>
	</__last_update>
	<write_uid type="dict">
		<type type="str">many2one</type>
		<string type="str">Last Updated by</string>
	</write_uid>
	<write_date type="dict">
		<type type="str">datetime</type>
		<string type="str">Last Updated on</string>
	</write_date>
	<display_name type="dict">
		<type type="str">char</type>
		<string type="str">Display Name</string>
	</display_name>
	<id type="dict">
		<type type="str">integer</type>
		<string type="str">Id</string>
	</id>
</fields>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://synconics.gitbook.io/rest-api/inspection-and-introspection/ir.model.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
