Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
50936 Tampilan

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
Buang

This will solve your problem.

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

Penulis Jawaban Terbai

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
Buang

Thanks you saved my time.

Post Terkait Replies Tampilan Aktivitas
4
Jan 20
6613
1
Nov 22
3235
2
Des 19
3394
1
Feb 23
3783
1
Feb 20
9251