Odoo Help

Welcome!

This community 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.

2

How display field of relational field into view?

By
John
on 4/17/13, 11:30 AM 5,547 views

Hello! I ve a question here the context: I've a relational field many2one into "model_a" (where the field is) to "model_b".

model_b contains the field "text".

For the moment, i ve the name of the model_b into the model_a, i 'd like to have the text of model_b into the field of model_a, but only the references, not a copy because text is big, and have to be consistency with other model.

in advance, thanks.

6

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 4/17/13, 11:48 AM

OpenERP many2one field return, normally, the field name of the relation class. For Example, if I have a many2one to res_partner, I will read the partner name in the relative field. A solution is to set the rec name of the class on the field that you want read. For example, if I want to read the partner's phone number (it's a stupid example, sorry!) I must do this in my module:

class mail_alias(osv.Model):
    _inherit = 'res.partner'
    _rec_name = 'phone'

So, I obtain the phone in many2one.

Another solution is to use a relation field that read the correct value passing by youa many2one

phone = 'model': fields.related('your_many2one', 'phone', type='char', string='Phone                  size=128, select=True, store=False, readonly=True),

Wow! quick answer, first answer and right answer, it works perfectly, a big thanks to you!

John
on 4/17/13, 12:08 PM

If the answer is the correct one, please set it as correct to help future user that search some answer and, if you want, vote it with a +1...:)

Francesco OpenCode
on 4/17/13, 12:16 PM

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/17/13, 11:30 AM
Seen: 5547 times
Last updated: 3/16/15, 8:10 AM