콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
51178 화면

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
1월 20
6903
1
11월 22
3491
2
12월 19
3616
1
2월 23
4012
1
2월 20
9504