Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
10451 Visualizzazioni

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)

Avatar
Abbandona
Autore

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

Risposta migliore

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.

Avatar
Abbandona
Risposta migliore

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

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
lug 15
10914
1
ott 15
9510
2
mag 24
10784
0
giu 23
78
6
gen 18
32710