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

Hi Community,

 I use self.id inside of compute function that is returning me " <odoo.models.NewId object at 0x7fb107e35be8>".

- I want to get record's id.

Any idea?

Thanks in advance.


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
Yes in odoo already saved record in compute not have ID use _origin or ids
for example

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

Hi!

How does your compute function look and for which entity are you using it? It sounds like the function is called for a new entity before it has actually been saved, which means that it does not yet have an ID. In this case Odoo returns the NewId object you are observing.

If this is the case, your function should be called at a later point and/or there should be a fallback for the case of objects that do not have an ID yet by checking if the returned ID is numeric.

อวตาร
ละทิ้ง
ผู้เขียน

already saved record shows the same error

This is impossible to diagnose without seeing your actual code.

คำตอบที่ดีที่สุด

Hello,


If your record is saved then you will get current record using self._origin

อวตาร
ละทิ้ง
ผู้เขียน

But its not working in compute function