我正在尝试制作一个简单的继承模块,以便可以在新的机会表单中添加更多字段,但 odoo 不喜欢我的代码。我是 Odoo 和 Python 的新手,所以不要怪我 :(
我的模块.py:
from openerp.osv import fields, osv
class crm_lead_mymodule(osv.osv):
_inherit = 'crm.lead'
_columns = {
'product_type' : fields.selection( [('basic', 'Basic'),('pro', 'Pro'),], ),
}
mymodule.xml:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="view_crm_opportunity_mymodule_form" model="ir.ui.view">
<field name="name">crm.lead.mymodule.inherit</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[@name='lead']" position="after">
<page string="Product Information">
<group col="3">
<field name="product_type"/>
</group>
</page>
</xpath>
</field>
</record>
</data>
</openerp>
在我的代码更改之后,我尝试了很多安装,直到我卸载它并且 odoo 崩溃了。我收到以下日志的“内部服务器错误”:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
...
...
...
File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 168, in load
model = cls._build_model(self, cr)
File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 593, in _build_model
original_module = pool[name]._original_module if name in parents else cls._module
File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 84, in __getitem__
return self.models[model_name]
KeyError: 'crm.lead'