Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
4147 มุมมอง

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.

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ธ.ค. 24
1383
Import Data From Another Model แก้ไขแล้ว
1
มี.ค. 24
2433
3
ต.ค. 23
8755
1
ก.ย. 23
3310
1
มิ.ย. 23
12446