Skip to Content
Menú
This question has been flagged
1 Respondre
50820 Vistes

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
Descartar

This will solve your problem.

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

Autor Best Answer

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
Descartar

Thanks you saved my time.

Related Posts Respostes Vistes Activitat
4
de gen. 20
6421
1
de nov. 22
3114
2
de des. 19
3286
1
de febr. 23
3653
1
de febr. 20
9194