Model Attribute _rec_name in the Odoo 17

CelineGeorge1 641 views 24 slides May 10, 2024
Slide 1
Slide 1 of 24
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24

About This Presentation

_rec_name is intended to define the record value used to display it in search for many2one , breadcrumbs and many other cases .


Slide Content

Model Attribute _rec_name in Odoo 17 Enterprise

Introduction Enterprise _rec_name is intended to define the record value used to display it in search for many2one , breadcrumbs and many other cases .

Steps Enterprise First of all we have to create a model class for creating the wizard. Also, don't forget to include the model in the security file and provide the necessary rights.

Enterprise

Steps Enterprise Next, we must create a view. The view should always be opened as ir.actions—act_window data. A menu item or button action defined in Python or XML code . We can make a menu and action window to see if our new views .

Enterprise

Enterprise

Steps Enterprise Now if you go to the contacts you will see a new menu added called student requests .

Enterprise

Steps Enterprise Now you will see the corresponding tree and form views of our new model .

Enterprise

Enterprise

Steps Enterprise As you can see in the breadcrumb , the record is called student.request.1 which is a combination of model name and id . This is the default name assigned to a record if there is no _rec_name attribute specified and no ‘name’ field is specified .

Steps Enterprise Now if we change the _rec_name the to student_name you will see that the default name of the record will the be value in the student_name field .

Steps Enterprise

Steps Enterprise Now if we change the _rec_name the to student_id you will see that the default name of the record will the be value in the student_id field .

Steps Enterprise

Steps Enterprise Now let us also see how it affects the search in a many2one field of our new model . For this let us add a new many2one field to res.partner model and add it to our view

Enterprise

Enterprise

Steps Enterprise As you can see in the many2one’s search, the record are in the combination of model name and id . This is the default name assigned to a record if there is no _rec_name attribute specified and no ‘name’ field is specified .

Steps Enterprise Now if we change the _rec_name the to student_name you will see that the default name of the record will the be value in the student_name field .

Steps Enterprise Now if we change the _rec_name the to student_id you will see that the default name of the record will the be value in the student_id field .

For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com