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 inherit from view to add an element in it ?

By
Oussama
on 7/21/14, 9:13 AM 1,306 views

Hello, I'm getting difficulties to add an element to existing view by inheriting it and adding the new element as specified in the documentation. In fact the original view is not changed, and the inherited view has no effect..

Here is what I get whether before or after adding the inherit view (which should add a page for Radiology ) : http://img11.hostingpics.net/pics/596530Screenshotfrom20140721132617.png

Here is the code of the original view : ( I pasted only the part specific to the <form> )

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
         <record id="view_oemedical_patient_form" model="ir.ui.view">
             <field name="name">oemedical.patient.form</field>
             <field name="model">oemedical.patient</field>
             <field name="priority" eval="8" />
             <field name="arch" type="xml">
              <form string="Patient" version="7.0">
                    <sheet>
                        <div>
                            <field name="photo" widget='image' class="oe_left oe_avatar"/>
                            <div>
                                 <h1>
                                    <field name="first_name" placeholder="First Name" style="width: 20%%" on_change="onchange_name(first_name, lastname, slastname, context)"  />
                                    <!-- some other fields -->
                                </h1>
                            </div>
                 <!-- some other code -->
                        </div>
                    <notebook>
                        <page string="General Information">
                            <group  col="6" colspan="4">
                                 <field name="blood_type" style="width: 8%%"/>
                                 <field name="rh" nolabel="1"/>
                                   <field name="ethnic_group" />
                            </group>
                            <group string="Contact Information">
                                <group>
                                    <label for="street" string="Address"/>
                                    <div>
                                        <field name="use_parent_address" class="oe_edit_only oe_inline" invisible="1"/>
                                        <label for="use_parent_address" class="oe_edit_only" invisible="1"/>
                                        <field name="street" placeholder="Street..." />
                     <!-- many other fields -->
                                </group>
                            </group>
                         </page>

<!-- other pages composing the notebook -->

                        <page string="Misc">
                            <group colspan="4" col="4">
                                <separator colspan="4" string="Patient Extra Information"/>
                                  <field name="general_info" nolabel="1"  colspan="4"/>
                            </group>
                            <newline/>
                            <group colspan="4" col="6">
                                <field name="deceased"/>
                                <field name="dod" attrs="{'invisible':[('deceased','=',False)],'required':[('deceased','=',True)]}"/>
                                <field name="cod" attrs="{'invisible':[('deceased','=',False)]}"/>
                            </group>
                        </page>

<!-- some other code -->

                    </notebook>
                 </sheet>
                 </form>
             </field>
         </record>

    </data>
</openerp>

And here is the code of the inherited view :

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>

        <record model="ir.ui.view" id="view_oemedical_patient_form_radio_logy">
            <field name="name">oemedical.patient.view.inherit.radio_logy</field>
            <field name="model">oemedical.patient</field>
            <field name="inherit_id" ref="oemedical.view_oemedical_patient_form" />
            <field name="type">form</field>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//notebook/page[@string='Misc']" position="before">
                        <page string="Radiology" id="page_radiology">
                            <notebook>
                                <page string="Main" id="page_ses_main">
                                    <group colspan="4" col="4" id="group_ses_holder2">
                                        <field name="ses"/>
                                        <field name="housing"/>
                                        <field name="education"/>
<!--                                        <field name="occupation"/>-->
                                    </group>
                                    <newline/>

<!-- other groups -->

                                </page>
                            </notebook>
                        </page>
                    </xpath>
                </data>
            </field>
        </record>

    </data>
</openerp>

Everything remains the same, no errors, nothing, the original view is not affected.. I tried to create a new database for my openerp and to re-install the module on it but nothing changed..

Any help please ?!

0

Koffi KPONOUGLO

--Koffi KPONOUGLO--
768
| 5 2 6
Lomé, Togo
--Koffi KPONOUGLO--

Koffi KPONOUGLO

Koffi KPONOUGLO
On 7/21/14, 11:03 AM

Before iherit view you have to the exact view_id by reading code or using web client (Setting -> Technical -> User Interface -> Views). You have and simple option whose consiste to activate the developper mode(Right Top of screen -> User Name -> About Odoo -> Activate developper mode). By doing this the Deboguer field will appear on every view.

After this, go the view you want to ihnerit   and choose option manage views in Deboguer field . You will get the way to inherit easly your 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

1 follower(s)

Stats

Asked: 7/21/14, 9:13 AM
Seen: 1306 times
Last updated: 3/16/15, 8:10 AM