Reputation: 940
I'm getting my first step into odoo. I'm trying to extend product model class like this.
from openerp.osv import osv,fields as fields
class product_product(osv.osv):
_name = 'product.product'
_inherit = 'product.product'
_columns = {
'products_ids':fields.one2many('product_application.version', 'version_id', string="Versions")
}
and getting the following error
File "/home/nano/ARCHIVOS/PycharmProjects/odoo/odoo/openerp/models.py", line 596, in _build_model
original_module = pool[name]._original_module if name in parents else cls._module
File "/home/nano/ARCHIVOS/PycharmProjects/odoo/odoo/openerp/modules/registry.py", line 102, in __getitem__
return self.models[model_name]
KeyError: 'product.product'
Can anyone point me a complete odoo v8 documentation, the official is poor
Upvotes: 4
Views: 1771
Reputation: 490
In odoo the _name creates a new table in the backend database.
So, here the problem is you are using while inheriting _name = 'product.product' which is already existing in the DB (base class product).
Also if you want normal inheritance no need of _name attribute, simply you can extend by _inherit only.
The kind of inheritance which you are using, in that the _name should not be equal to _inherit (_name != _inherit). So, either give a new name to _name='new.name'
for more clarification check this link
https://www.odoo.com/documentation/8.0/howtos/backend.html
Upvotes: 2
Reputation: 669
You are getting 'Keyerror'
so please check whether you gave correct depends in openerp.py ie, you have to give 'product' in depends
Give like this:- 'depends': ['base', 'product'],
Hope this helps...
Upvotes: 9
Reputation: 1164
Try this:
from openerp.osv import fields,osv
class product_product(osv.osv):
_name = 'product.product'
_inherit = 'product.product'
_columns = {
'products_ids':fields.one2many('product_application.version', 'version_id', string="Versions")
}
I don't know why you're using "fields as fields"?
Or else check that have you installed "Product" module?
Upvotes: 1