Odoo Help


_inherit , im having a hard time to understand

Lakay lakay
on 9/8/14, 4:05 AM 885 views

im having a hard time understanding _inherit, they said that with _inherit you could override a object , for example res.partner , 

 i have created a new module folder on odoo/addons path. and on my module.py i added the below script

with this python script they said that you should be able to add fields into the res.partner object


~SOME OF MY working codes here



class res_partner(osv.osv)


_columns={  my_var:fields.integer('my number'),


after updating and upgrading modules in odoo, 

why is it that i cant find the field 'my_var' into the Settings>Database Structure > Models    and search for res.parner > fields 



hi, Just confirm that you have added your file into __init__.py file.

Emipro Technologies Pvt. Ltd.
on 9/8/14, 6:02 AM



| 5 3 6
Jakarta, Indonesia
On 9/8/14, 6:35 AM

my_var need to be a string, so your code should be something like:

class res_partner(osv.osv)


_columns={  'my_var': fields.integer('my number'),


Note that osv.osv has been deprecated in 7.0 use orm.Model instead.

thanks for that info man

Lakay lakay
on 9/8/14, 8:37 PM

im getting NameError: name 'orm' is not defined when i changed osv.osv to orm.Model

Lakay lakay
on 9/8/14, 8:52 PM

in the header im using from openerp.osv import osv,fields do i need to change this one?

Lakay lakay
on 9/8/14, 8:53 PM

Yes you need to change it to openerp.osv import orm, fields. Note that if you take out osv, you might want to search for all osv usages. Common example is use of osv.except_osv which need to be changed to orm.except_orm (same signature just different name).

on 9/8/14, 11:38 PM

All the above answers are correct, but perhaps you are forgetting the most important thing: have you restarted your OpenERP server?

Everytime you make a change in your python files, the server has to be restarted, to recompile your python code. If even that doesn't work, remove any .pyc files on your module and then restart your OpenERP server again.

thanks it works! by the way when i remove .pyc files it always reappear and why? also what are these .pyc for?

Lakay lakay
on 9/8/14, 9:07 PM

.pyc is the compiled version of your .py file. At run time, .pyc is the file that will be read unless if there is a newer (by timestamp) .py file, in which python will (re-)generate the .pyc file.

on 9/8/14, 11:40 PM

.pyc are exactly what @john doe said. if it worked, you might want to mark it as accepted, so that other users may know what is the correct solution for this kind of problem.

Luis Filipe Castanheira
on 9/9/14, 5:28 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

2 follower(s)


Asked: 9/8/14, 4:05 AM
Seen: 885 times
Last updated: 3/16/15, 8:10 AM