Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
50960 Lượt xem

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)

Ảnh đại diện
Huỷ bỏ

This will solve your problem.

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

Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

Thanks you saved my time.

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 1 20
6648
1
thg 11 22
3245
2
thg 12 19
3429
1
thg 2 23
3796
1
thg 2 20
9269