Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
4079 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Auteur

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

Gerelateerde posts Antwoorden Weergaven Activiteit
0
dec. 24
1317
1
mrt. 24
2361
3
okt. 23
8622
1
sep. 23
3240
1
jun. 23
12362