This question has been flagged
4 Replies
18498 Views

Hi, I have modified the form view by inheritance by the following code in the py file:

-----------------------------------------------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record model="ir.ui.view" id="view_ct_form">
        <field name="name">res.partner.form</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form" />
        <field name="arch" type="xml">

            <field name="street2" position="attribute">          
            <attribute name="invisible">1</attribute>
            </field>
       </field>          
   </record>
-----------------------------------------------------------------------------------------------------------------------------------

Now I would like to create my own form view, "view_ct_form", instead of replacing fields, adding fields, deleting fields and so on. What is the code I should use?

Thanks a lot.

Avatar
Discard

Hi Frankie, Can you brief more about your question what exactly you want to do for creating a view, because when you say "my own form view" then  along with it you will have to modify the "action" * which will open your view instead of default. If you inherit a view than it will be mandatory to use the *"position" *attribute for putting a field *"after, before or replace"*  on the form view.

Hi Hiren,

I am new to openerp.

I want to change "res_partner_view.xml". More accurately, I only want to change "view_partner_form" and "view_partner_tree" and keep others, such as action, menu-item, unchanged.

How can it be done?

Furthermore, can I copy the whole "res_partner_view.xml" to a new xml file called "new_view.xml" and just edit "view_partner_form" and "view_partner_tree"? Should I copy other files, e.g. css, __openerp__.py?

Thanks a lot.

Frankie


On Fri, Jul 4, 2014 at 8:32 PM, <Hiren@mail1.openerp.com> wrote:

Hi Frankie, Can you brief more about your question what exactly you want to do for creating a view, because when you say "my own form view" then  along with it you will have to modify the "action" * which will open your view instead of default. If you inherit a view than it will be mandatory to use the *"position" *attribute for putting a field *"after, before or replace"*  on the form view.

Hiren Vora,
Sr. OpenERP Technical Engineer,
Emipro Technologies, India.
www.emiprotechnologies.com
info@emiprotechnologies.com

Sent by OpenERP S.A. using OpenERP. Access your messages and documents in Odoo

Best Answer

first of all you havre to create the form view like below....        

<record id="myfirst_form_view" model="ir.ui.view">
            <field name="name">scholar.details.form</field>
            <field name="model">scholar.details</field> ------>this is the model name(class name)
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="student.details" version="7.0">
                    <sheet string="student">
                        <h1>
                            <label string="Add Scholar Details"/>
                        </h1>
                        <group string="My First Form View">
                            <field name="name"/>
                            <field name="age"/>
                            <field name="dob"/>
                            <field name="stream_id"/>
                            <field name="status"/>
                        </group>
                        <field name="subject_id"/>
                    </sheet>
                </form>
            </field>
        </record>

then you have to create action view like...

        <record id="action_scholar_details" model="ir.actions.act_window">
            <field name="name">My First Action</field>
            <field name="res_model">scholar.details</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field> ----> here we provide for both tree and form view , while tree view will come erlier
            <field name="help" type="html">
                <p class="oe_view_nocontent_create">
                    test
                </p><p>
                    Description goes Here.
                </p>
            </field>
        </record>

and finally you have to create the menu item like..

        <menuitem id="menu_base_scholar" name="Scholar"/>
        <menuitem id="menu_section_scholar" parent="menu_base_scholar" name="Scholar_Record"/>
        <menuitem id="menu_item_scholar" parent="menu_section_scholar" name="Record Codes" action="action_scholar_details"/>

 

if this will work then its fine else you have to create and add tree view also (you can add this one before or after the form view)

        <record id="myfirst_tree_view" model="ir.ui.view">
            <field name="name">scholar.details.tree</field>
            <field name="model">scholar.details</field>
            <field name="arch" type="xml">
                <tree string="My First Tree View">
                    <field name="name"/>
                    <field name="age"/>
                    <field name="dob"/>
                    <field name="subject_id"/>
                    <field name="stream_id"/>
                    <field name="status"/>
                </tree>
            </field>
        </record>

I think this will surely help you in creating your own view.

Avatar
Discard