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

Hello

I inherit a class with _inherit in a models.Model construced class and define some extra fields and methods.

Now, I want to access a parent class field in a domain statment on one of those fields as well as in an @api.depends decorator.

However, i cannot figure out how to get access to those fields as thei are not available from within the class.

Note: within the method which is decorated with @api.depends, they are accessible normally, but on the identation level of the class itself theay are not... Please help, I can't figure it out even trying to decifer the core python files (models.py api.py fields.py)

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

https://github.com/odoo/odoo/issues/1530

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

Both in domains and @api.depends statements, the fields always appear as strings. In other words, you never refer to the fields themselves, but instead you refer to their nameTherefore nothing special is needed to access inherited fields: the ORM knows how to resolve the field name.

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

Ejemplo: 

 @ api.one

@api.depends('numero')

def _obtener_cliente(self):

para rec en auto:

Modelo = self.env [ 'bl']

bl = model.browse ([rec.no_bl.id])

rec.customers = bl.customers

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ค. 15
10909
New api search domain id and condition? แก้ไขแล้ว
1
ต.ค. 15
9507
Odoo v15: How to do domain dynamic? แก้ไขแล้ว
2
พ.ค. 24
10780
0
มิ.ย. 23
78
@api.depends not triggering function แก้ไขแล้ว
6
ม.ค. 18
32703