Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odoo 8.0 product_product inherit extend class

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

like image 628
Mariano DAngelo Avatar asked Dec 15 '22 12:12

Mariano DAngelo


2 Answers

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

like image 138
Baiju KS Avatar answered Dec 28 '22 09:12

Baiju KS


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

like image 44
shravan cherukuri Avatar answered Dec 28 '22 11:12

shravan cherukuri