Odoo Help

0

_rec_name - predefined fields

By
omprakash
on 5/17/13, 9:07 AM 10,443 views

Hai Friends ,

 First I thank everyone who give good guideline for newbie in OpenERP . I have question regards predefined fields - _rec_name  in OpenERP .
  1. Its not clear for me , _rec_name predefined fields in OpenERP . Friends can you please explain with sample module .It more useful for clear understanding .

Thanks & Regards OMPRAKASH.A

6

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10470
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 5/17/13, 12:12 PM

_name is used to define object like account.invoice, sale.order, purchase.order, res.users.

When you have name field in your columns, you don't need to define field in _rec_name. OpenERP takes name field by default.

You have seen name in any form when you select many2one field. For example in Sale Order when you select Customer, you can see Customer's Name in that many2one field. Now if you want to show Customer's Phone Number in many2one field, you have to define phone field in _rec_name like this: _rec_name = 'phone'

If your columns don't have any name field then you have to define any field in _rec_name.

There are other reasons which Prakash described in his answer.

Hi Sudhir Arya, Thanks for your reply . I am new for OpenERP , If my question are very silly please don't mistake . I am very interest to know about OpenERP . 1. > From your point I can understand that _rec_name not needed until _name is defined . But if i create a <objectname>.py class _name is mandatory . So I must declare the _name fields . 2.> If i define _rec_name how can i make use .

omprakash
on 5/18/13, 5:35 AM

This is my sample code please explain with this ...< Test.py > from osv import fields,osv class test(osv.osv): _name = 'sodexis' _rec_name = 'data_id' _columns = { 'name' : fields.char('name' , required = 1 , size = 30 ), 'age' : fields.integer('age' , store = False), 'data_id':fields.many2one('test', 'data_id', required=False) } test()

omprakash
on 5/18/13, 5:37 AM

Please explain with this example , And once i thank you both for such guideline ... Thanks regards ----OMPRAKASH.A

omprakash
on 5/18/13, 5:38 AM

I am talking about name field in _columns not _name. There is nothing to do with _name.

Sudhir Arya (SA)
on 5/18/13, 7:00 AM

In your code you have defined name field

`name`: fields.char('name', required=1, size=30)

So you don't need to define _rec_name because OpenERP takes name field by by default.

Sudhir Arya (SA)
on 5/18/13, 7:03 AM

Hi Suhir Arya , Thanks for your reply ..

omprakash
on 5/20/13, 11:45 AM
0
Nivas
On 1/20/17, 12:31 PM

Hi,

I have another doubt here.I want to know the way to find which field is applied in _rec_name in the particular model.

I have taken that model id from ir.model table and also I could find all the fields list created in that model through ir.model.fields table.But I could not find which field is used in _rec_name

Could you please help me?


0

Prakash

--Prakash--
Prakash
3203
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 5/17/13, 9:19 AM

In fields.many2one("table.name", output)

Default name_get method return the output value "name" field value in the table.

suppose in the table contain no "name" field then we can use _rec_name = field_name

Now in name_get method return _rec_name field value.

Hi Prakash , Thanks for your reply . I have doubt , _name is mandatory then how can I use _rec_name ? If you explain with sample code , It make more useful for me & once again thanks for your reply

omprakash
on 5/17/13, 11:38 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 5/17/13, 9:07 AM
Seen: 10443 times
Last updated: 1/20/17, 12:31 PM