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

I have a model where I am simply trying to copy the integer value from the field named "id" to a variable so that I can pass it to another model and store it so that it can be reference later. I'm doing this in an automated action.

my_id = record.id

new_order=env['sale.order'].create({'x_quote_id': my_id})

The trouble is that it always returns 0.

Is there another way I can recall and store the value?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Can you post your full code of the automated action. I think the problem is 'my_id = record.id'. Otherwise, why dont you make a relationship between two models. I mean you want to store the value of id of model A in model B so you can reference to the records of model A in model B, right? So simply just have a related fields in model B, namely 'x_quote_id' and have it relates to the model A.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

That is ultimately what i did.  I just still don't understand why trying to set my_id = record.id doesn't work.  It seems that logically it would store the integer.  Strange behavior in my view.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ต.ค. 21
6507
1
ก.พ. 25
1301
1
พ.ย. 23
2225
2
ธ.ค. 23
5847
1
พ.ย. 22
2687