Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
50911 Vizualizări

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)

Imagine profil
Abandonează

This will solve your problem.

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

Autor Cel mai bun răspuns

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

Imagine profil
Abandonează

Thanks you saved my time.

Related Posts Răspunsuri Vizualizări Activitate
4
ian. 20
6603
1
nov. 22
3224
2
dec. 19
3362
1
feb. 23
3770
1
feb. 20
9245