我一直致力于在我的 openerp 服务器 v7 中创建一个自定义模块。当我使用 win 7 时,我在我的 eclipse IDE 上运行 python 代码。我在我的模块上创建了一个按钮,它将在 click 上加载一个新表单。现在,当我单击按钮时,新表单正在加载,但我收到“openerp 服务器错误”。我定义的字段也不存在于我的新表单中。我不知道我哪里错了。请帮忙。
希望提出建议
这是我的python代码
from osv import fields, osv
import time
class my_module(osv.osv):
_name="my.module"
_columns={
'name':fields.char('Name',size=64),
'proj':fields.char('Proj-Details',size=64)
}
def add_field(self,cr,uid,ids,context=None):
return {
'name':'formview',
'view_mode': 'form',
'view_type': 'form',
'res_id' : 'form_view_action2', # id of the object to which to redirected
'res_model': 'ir.actions.act_window', # object name
'type': 'ir.actions.act_window',
'target': 'new' # if you want to open the form in new tab
}
class new_module(osv.osv):
_name="new.module"
_columns={
'date':fields.date('date')
}
这是我的xml代码
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="from_view_form">
<field name="name">from.view.form</field>
<field name="model">my.module</field>
<field name="arch" type="xml">
<form string="Form" version="7.0">
<group>
<field name="name" />
<field name="proj" />
<button name="add_field" string="Add Field" type="object" class="oe_highlight" />
</group>
</form>
</field>
</record>
<record model='ir.actions.act_window' id='form_view_action2'>
<field name="name">Form</field>
<field name="res_model">new.module</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="context">{}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new record.
</p>
<p>This is a test class developed to learn Openerp.</p>
</field>
</record>
<record model='ir.actions.act_window' id='form_view_action'>
<field name="name">Form</field>
<field name="res_model">my.module</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new record.
</p>
<p>This is a test class developed to learn Openerp.</p>
</field>
</record>
<menuitem name="newforms" id="newforms_ID" sequence="110" />
<menuitem name="newforms2" parent="newforms_ID" id="newforms2_ID" sequence="0" />
<menuitem name="newforms3" parent="newforms2_ID" id="newforms3_ID" action='form_view_action' />
<menuitem name="newforms4" id="newforms4_ID" action='form_view_action2' />
</data>
</openerp>