跳至內容
選單
此問題已被標幟
3 回覆
10436 瀏覽次數

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
7月 15
10908
1
10月 15
9507
2
5月 24
10780
0
6月 23
78
6
1月 18
32703