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

Hello, I was trying to understand decorator @api.dependens_context in odoo but I didn't find any document explaining it clearly can anyone explain it clearly with example and what is used for, Thanks and BR.




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

Hi,

Here is the link to the documentation:

https://www.odoo.com/documentation/17.0/developer/reference/backend/orm.html?highlight=api%20depends%20con#odoo.api.depends_context


Hope it helps

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

Hello ZiadHamdii

We use the ''@api.depends_context'' decorator for non-stored ‘compute’ methods to indicate the context dependencies for these methods. 

The arguments passed will be the key in the context’s dictionary.

example:

@api.depends_context('company') 
def _compute_currency_id(self): self.currency_id = self.env.company.currency_id

Thanks!!


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ส.ค. 25
2648
1
ก.ค. 25
1032
1
ส.ค. 25
1151
0
พ.ค. 25
1490
2
เม.ย. 25
3645