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

I have this code onchange

@api.onchange('the_geom')
    def _onchange_cor(self):
        if self.the_geom != False:
            self.env.cr.execute('SELECT the_geom from geolocalizacion_plot')
            self.cor2=self.env.cr.fetchone()[0]
            self.cor=self.id

but self.id returns <openerp.models.NewId object at 0x7f904b586e10>

how to get the id of self (the current record)

อวตาร
ละทิ้ง

This will solve your problem.

Reference: https://www.youtube.com/watch?v=eYVD_m6-jz8&t=4s

ผู้เขียน คำตอบที่ดีที่สุด

In on_changes odoo creates a new object and replaces self with it. The origin object, what you are looking for can be found under self._origin.id

อวตาร
ละทิ้ง

Thanks you saved my time.

Related Posts ตอบกลับ มุมมอง กิจกรรม
4
ม.ค. 20
6868
1
พ.ย. 22
3467
2
ธ.ค. 19
3588
1
ก.พ. 23
3984
1
ก.พ. 20
9465