Odoo Help


Inheritance by Delegation: Accessing parent class many2one field?

on 6/9/13, 8:49 AM 1,557 views


I am working with the product.product class that inherits by delegation from product.template. I want to access field uos_id from the parent class. The field is defined as fields.many2one('product.uom', 'Unit of Sale',help='Some text').

I tried to access the fields as follows:

product_obj = self.pool.get('product.product')
product = product_obj.browse(cr, uid, product_id, context=context2)
uom = product.uos_id

The code crashes some lines further because (I guess) the variable is empty. I suspect the issue is in the way I access the many2one field because when I use field uos_coeff from the parent class, it works fine (the field is defined as a fields.float('Unit of Measure -> UOS Coeff', digits_compute= dp.get_precision('Product UoS'), help='Coefficient')

Any idea of what's wrong?

Fixed: the proper syntax is uom = product.uos_id.id

on 6/9/13, 9:20 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 6/9/13, 8:49 AM
Seen: 1557 times
Last updated: 3/16/15, 8:10 AM