Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
50954 Vues

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
Ignorer

This will solve your problem.

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

Auteur Meilleure réponse

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
Ignorer

Thanks you saved my time.

Publications associées Réponses Vues Activité
4
janv. 20
6648
1
nov. 22
3244
2
déc. 19
3420
1
févr. 23
3795
1
févr. 20
9268