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

How to create my own view?

By
Frankie Chan
on 7/4/14, 7:57 AM 1,871 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.

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 - CEO at Emipro Technologies Pvt. Ltd. India
on 7/4/14, 8:32 AM
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

Frankie Chan
on 7/4/14, 3:06 PM
0
Manoj
On 7/4/14, 8:19 AM

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.

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

2 follower(s)

Stats

Asked: 7/4/14, 7:57 AM
Seen: 1871 times
Last updated: 3/16/15, 8:10 AM