İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
50877 Görünümler

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)

Avatar
Vazgeç

This will solve your problem.

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

Üretici En İyi Yanıt

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

Avatar
Vazgeç

Thanks you saved my time.

İlgili Gönderiler Cevaplar Görünümler Aktivite
4
Oca 20
6550
1
Kas 22
3182
2
Ara 19
3335
1
Şub 23
3716
1
Şub 20
9226