在我将CRM模块继承到Openerp中的自定义模块后,我需要显示树视图而不是窗体视图

时间:2014-02-05 05:47:41

标签: openerp openerp-7

我已成功将CRM模块继承到我的自定义模块中。我可以查看表单视图但我需要首先显示树视图。当我点击主菜单中的Lead按钮时,我能够显示表单view(比如在img1中),但是我需要显示树视图(就像在img 2中一样)

img 1 Img 1

img 2 Img2

lead_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

  <record id="view_lead_tree" model="ir.ui.view">
        <field name="name">bala.lead</field>
        <field name="model">bala.lead</field>
        <field name="arch" type="xml">
            <tree string="Leads">
                <field name="contact_name"/>
                <field name="lead_source"/>
                <field name="lead_status"/>
            </tree>
        </field>
</record>


 <!-- ========================This is Form layout===============================-->
<record id="crm_case_form_view_leads_extended" model="ir.ui.view">
<field name="name">CRM - Leads Form</field>
<field name="model">bala.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads" />
<field name="arch" type="xml">
    <field name="email_from" postion="replace"/>
    <field name="contact_name" position="replace"/>
    <label for="contact_name" position="replace">
      <br/>
    </label>
    <xpath expr="//label[@for='street']" position="before">
                <field name="contact_name"/>
    </xpath>
    <xpath expr="//label[@for='section_id']" position="before">
                <field name="lead_source"/>
                <field name="lead_status"/>
    </xpath>

    <field name="function" position="replace"/>
    <field name="partner_name" position="replace"/>
    <field name="priority" position="replace"/>
    <field name="categ_ids" position="replace"/>
    <field name="partner_id" position="replace"/>

</field>
</record>
<!-- ===========================Action layout=========================== -->
<record id="new_lead" model="ir.actions.act_window">
    <field name="name">Leads</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">bala.lead</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
    <field name="view_id" ref="view_lead_tree"/>
</record>
<!-- ===========================Menu Settings=========================== -->
<menuitem name ="Lead" id = "menu_lis_lab" />
  <menuitem name="Leads" id="sub_lead" parent="menu_lis_lab" />
    <menuitem name="Create Lead" id="create_lead" parent="sub_lead" action="new_lead"/> 
</data>
</openerp>

然后点击任何导致我得到img 3(无效视图)并点击创建按钮img 4正在显示,但我需要获取img1

img 3 img3  img 4 img4

1 个答案:

答案 0 :(得分:2)

将树视图添加到xml文件中,您可以根据需要在此添加更多字段

<record id="view_lead_tree" model="ir.ui.view">
        <field name="name">bala.lead</field>
        <field name="model">bala.lead</field>
        <field name="arch" type="xml">
            <tree string="Leads">
                <field name="contact_name"/>
                <field name="lead_source"/>
                <field name="lead_status"/>
            </tree>
        </field>
</record>

更新你的act_window

<record id="new_lead" model="ir.actions.act_window">
    <field name="name">Lead</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">bala.lead</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
    <field name="view_id" ref="view_lead_tree"/>
</record>

希望这会对你有所帮助。