تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
8547 أدوات العرض

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.

الصورة الرمزية
إهمال
أفضل إجابة

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" .

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

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...

الصورة الرمزية
إهمال
الكاتب

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
مايو 18
4231
1
مارس 15
4674
3
أبريل 25
4776
4
يناير 24
23217
Attrs attribute تم الحل
2
يناير 24
2515