跳至內容
選單
此問題已被標幟
1 回覆
4095 瀏覽次數

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
1328
1
3月 24
2382
3
10月 23
8651
1
9月 23
3249
1
6月 23
12410