콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
13745 화면

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.

아바타
취소
베스트 답변

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!

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...:)

관련 게시물 답글 화면 활동
2
3월 15
9098
0
4월 22
2025
0
3월 15
5509
0
3월 15
3653
0
3월 15
3483