تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
50949 أدوات العرض

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)

الصورة الرمزية
إهمال

This will solve your problem.

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

الكاتب أفضل إجابة

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.

المنشورات ذات الصلة الردود أدوات العرض النشاط
4
يناير 20
6644
1
نوفمبر 22
3241
2
ديسمبر 19
3407
1
فبراير 23
3793
1
فبراير 20
9263