Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
15519 มุมมอง

I am having a button in product form. And on click, perform an action based on javascript. But to do that action I need to get the current product id in the js file. How can I get the id in js file?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Akhill:

In your .py method just call self._id to get the current id.

In js just call this.id to get the current id

อวตาร
ละทิ้ง
ผู้เขียน

Am not getting right after giving "this.id" in js file. In js file what does "this" represents? After looking in some usages in odoo js files, its the current page or widget you are working na?

in js, this.id represents the current recodr id

คำตอบที่ดีที่สุด

Example: https://www.odoo.com/forum/help-1/question/backend-javascript-how-transfer-current-id-of-form-object-to-script-87022

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.ค. 25
271
1
ก.ค. 25
5045
0
ก.ค. 25
609
0
มิ.ย. 25
691
1
มิ.ย. 25
862