跳至內容
選單
此問題已被標幟
1 回覆
50951 瀏覽次數

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.

相關帖文 回覆 瀏覽次數 活動
4
1月 20
6647
1
11月 22
3244
2
12月 19
3415
1
2月 23
3794
1
2月 20
9266