Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
8431 Ansichten

Hello, I customized my sale.order adding some fields by a custom module. I need to create a new menu item which it shows the typical tree list with only this fields that I added, but I need also the form view with this new fields when I click in the row that I want to modify.

I did this xml:

<openerp>
    <data>
        <record id="view_commission_commercial_liquidacion_tree" model="ir.ui.view">
            <field name="name">commission.commercial.liquidacion.tree</field>
            <field name="model">sale.order</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                    <tree string="Comisiones">
                        <field name="importe_total" select="1"  />
                        <field name="importe1" select="1"  />
                        <field name="fecha1" select="1"  />
                        <field name="estado1" select="1"  />
                        <field name="importe2" select="1"  />
                        <field name="fecha2" select="1"  />
                        <field name="estado2" select="1"  />
                        <field name="importe_ajuste" select="1"  />
                        <field name="fecha_ajuste" select="1"  />
                        <field name="estado_ajuste" select="1"  />
                    </tree>
            </field>
        </record>
        <record id="view_commission_commercial_liquidacion_form" model="ir.ui.view">
            <field name="name">commission.commercial.liquidacion.form</field>
            <field name="model">sale.order</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Liquidación">
                    <field name="importe_total" select="1"/>
                    <field name="importe1" select="1"/>
                    <field name="fecha1" select="1"/>
                    <field name="estado1" select="1"/>
                    <field name="importe2" select="1"/>
                    <field name="fecha2" select="1"/>
                    <field name="estado2" select="1"/>
                    <field name="importe_ajuste" select="1"/>
                    <field name="fecha_ajuste" select="1"/>
                    <field name="estado_ajuste" select="1"/>
                    <field name="commercial_id" select="1"/>
                </form>
            </field>
        </record>
        <record model="ir.actions.act_window" id="open_view_commission_commercial_liquidacion_tree">
            <field name="name">Liquidaciones</field>
            <field name="res_model">sale.order</field>
            <field name="view_type">tree</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="view_commission_commercial_liquidacion_tree"/>
        </record>
        <menuitem name="Comisiones" parent="base.menu_base_partner" id="menu_commission_commercial_liquidacion_open_view"/>
        <menuitem name="Liquidación" parent="menu_commission_commercial_liquidacion_open_view" id="menu_commission_commercial_liquidacion_open_view_list" action="open_view_commission_commercial_liquidacion_tree"/>
    </data>
</openerp>

With this xml, it appears my custom list but without search box, and I need it, and when you click on form view (not clicking on the row, but on the form icon), it appears the original view of sale.order. I don't know how link my custom form view.

Somebody could help me, please?

Thank you in advance.

Avatar
Verwerfen
Beste Antwort

When you have to add Some Fields to an existing model you need to Inherit the model both in Python file and its xml file. In The Xml file you need to inherit the original Sale order form view and Then add your custom Fields for making them visible In the View.

THIS is how you inherit the sale order view. Use this code for your form view and Your Fields will Appear.

    <record id="view_commission_commercial_liquidacion_form" model="ir.ui.view">
        <field name="name">commission.commercial.liquidacion.form</field>
        <field name="model">sale.order</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
          <field name="create_date" position="after">
                <field name="importe_total" select="1"/>
                <field name="importe1" select="1"/>
                <field name="fecha1" select="1"/>
                <field name="estado1" select="1"/>
                <field name="importe2" select="1"/>
                <field name="fecha2" select="1"/>
                <field name="estado2" select="1"/>
                <field name="importe_ajuste" select="1"/>
                <field name="fecha_ajuste" select="1"/>
                <field name="estado_ajuste" select="1"/>
                <field name="commercial_id" select="1"/>
        </field>
    </record>

Here the line <field name="inherit_id" ref="sale.view_order_form"/> inherits the original sale.order form record where "sale" is the module name and form record name is "view_order_form" .

Avatar
Verwerfen
Autor Beste Antwort

Hello Subbin, thank you for you answer. I already use your exemple when I customized the sale.order view, but now, I'm trying to devel a new menu item with a new custom form and tree view. Here I put: <field name="view_mode">tree,form</field> <field name="view_id" ref="view_commission_commercial_liquidacion_tree"/> And when I click to the menu item it access to my tree view but when you click un form, it access to original form and I want to access to my form view: view_commission_commercial_liquidacion_form But I don't know how do it...

Avatar
Verwerfen
Autor

I found the solution here: http://forum.openerp.com/forum/topic14068.html

Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Mai 18
4088
1
März 15
4542
3
Apr. 25
4478
4
Jan. 24
22973
2
Jan. 24
2339