0

嗨,我在 openerp 7 中创建了一个自定义模块。我正在使用 eclipse 来运行代码。我在我的模块上放了一个按钮,点击它会打开一个新表单。该按钮正在加载表单,但表单上没有字段。我不知道我错在哪里。请指导我。

希望提出建议

这是我的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.window</field>
            <field name="arch" type="xml">
                <form string="Form" version="7.0">
                    <group>
                        <field name="name" />
                        <field name="bdate" />
                        <button name="display" string="Add Field" type="object"  class="oe_highlight" />
                    </group>
                </form>
            </field>
        </record>
        <record model='ir.ui.view' id='2'>
            <field name="name">Form</field>
            <field name="model">my.window</field>
            <field name="arch" type="xml">
                <form string="Form" version="7.0">
                    <group>
                        <field name="name" />
                        <field name="bdate" />
                    </group>
                </form>
            </field>
        </record>
        <record model='ir.actions.act_window' id='form_view_action'>
            <field name="name">Form</field>
            <field name="res_model">my.window</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' />
    </data>
</openerp>

这是我的python代码

from osv import fields, osv
import time

class my_window(osv.osv):
    _name="my.window"
    _columns={
         'name':fields.char('Name',size=64),
         'bdate':fields.date('BirthDate')     
            }

    def display(self,cr,uid,ids,context=None):
           return {
        'name':'formview', 
        'view_mode': 'form',
        'view_type': 'form',
        'res_id' : '2', # 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
}
4

1 回答 1

0

您给出的 res_model 是错误的。请给它'from.view.form' 请检查以下链接 方法返回值在OpenERP中调用另一个表单

于 2013-07-19T07:15:10.430 回答