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

Hi there,

I have two different models.
First model has the fields:
- name;
- destiny;

Second model has a field named "any_value".

When I am working on the second model and save it, I need to search for the field "destiny" on first model and change it's value to the same value entered on the field "any_value" of second form.

How can I do that?

Thank you in advance


아바타
취소
베스트 답변

first_model_rec_set = self.env['first.model'].search([your search domain])

for rec in first_model_rec_set:

    rec.destiny = self.any_value


Or you can use browse instead of search. 

If you have a relational field, say a Many2one from model 2 to model 1, then you could write something like 

self.many2one_field.destiny = self.any_value

아바타
취소
작성자

@Meaningless Life, thank you. Using the first sintaxe I was abble to do it.

관련 게시물 답글 화면 활동
0
12월 24
1489
1
3월 24
2550
3
10월 23
9060
1
9월 23
3430
1
6월 23
12578