Odoo 9无法继承purchase.order

时间:2016-04-12 10:53:32

标签: openerp odoo-9

我正在尝试将自定义字段添加到Odoo 9中的 purchase.order 对象。我已经将此操作添加到系统的其他部分而没有问题。但是我一直在努力。

  

KeyError:找不到model purchase.order

这是我的代码

class purchase_order(osv.Model):
    _inherit = "purchase.order"
    _columns = {
        'purchase_reference': fields.char("Purchase Reference")
    }

purchase_order()

我无法看到问题所在。我甚至可以在Odoo GitHub回购中找到与我完全相同的代码。

任何想法?

3 个答案:

答案 0 :(得分:1)

As from the shared code i have find that you are trying to inherit model purchase.order [ _inherit = "purchase.order"] and want to know how to inherit it in the right way .

In ODOO it's a basic necessity that whenever you want to inherit a model that is create in some another module , you must associate the module name in the keyword depends of __openerp__.py.

Below i am just posting the __openerp__.py of a test module :

{
'name': 'My Module',
'version': '0.1',
'author': 'Prakash Sharma ',
'category': 'Sale',
'website': 'http://stackoverflow.com/users/5133838/prakash-sharma',
'description': """This is a test module .""",
'depends' : ['purchase'],
'demo': ['my_module.xml'],
'data': ['views/my_module.xml' ],
'auto_install': False,
'installable': True,
}

You can try this link also for the detail exploration of ODOO Manifest File __openerp__.py This may help in your case.

答案 1 :(得分:0)

Emipro给出了我认为正确的答案。

我建议你在Odoo 9上为你的客户开发使用新的API,你会发现它更方便。从这里开始:https://www.odoo.com/documentation/9.0/howtos/backend.html

答案 2 :(得分:0)

确保已安装购买模块,手动安装或在自定义模块的

中添加“购买”
    __openerp__.py 

将文件作为'depends'的值