Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
4091 Tampilan

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


Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Penulis

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

Post Terkait Replies Tampilan Aktivitas
0
Des 24
1325
1
Mar 24
2380
3
Okt 23
8637
1
Sep 23
3246
1
Jun 23
12399