Odoo Help

1

obtain the id of a self (onchange) odoo

By
josemi
on 4/26/16, 11:41 AM 4,115 views

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)

8
josemi
On 5/19/16, 3:39 AM

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

Thanks you saved my time.

Ubaid ur Rehman
on 12/6/16, 2:46 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 4/26/16, 11:41 AM
Seen: 4115 times
Last updated: 4/14/17, 4:18 AM