跳至内容
菜单
此问题已终结
1 回复
50897 查看

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
6601
1
11月 22
3199
2
12月 19
3352
1
2月 23
3753
1
2月 20
9239