Odoo Help


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.


Inheritance by Delegation: Accessing parent class many2one field?

on 6/9/13, 8:49 AM 1,108 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

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

0 follower(s)


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