Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Custom Views clicking menuitem

By
Victor
on 12/11/13, 12:23 PM 1,574 views

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.

0
Subhin P V
On 12/12/13, 1:27 AM

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

0
Victor
On 12/12/13, 5:22 AM

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

Victor
on 12/12/13, 8:08 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 12/11/13, 12:23 PM
Seen: 1574 times
Last updated: 3/16/15, 8:10 AM