Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to Access Fields of parent class in domain and @api.depends() statement

By
David Arnold
on 8/2/14, 3:59 PM 1,898 views

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

David Arnold
on 8/3/14, 4:21 PM
1

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.

0
Juan Carrasquel
On 8/29/16, 11:15 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/2/14, 3:59 PM
Seen: 1898 times
Last updated: 8/29/16, 11:15 AM