Odoo Help

Welcome!

This community 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.

0

obtain the id of a self (onchange) odoo

By
josemi
on 4/26/16, 11:41 AM 1,001 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)

1
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/26/16, 11:41 AM
Seen: 1001 times
Last updated: 5/19/16, 3:40 AM