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

OpenERP v7.0 inherit view to add field

By
clement zotti
on 5/15/14, 5:06 PM 2,618 views

Hello,

It's a couple of days I try and I always run into a wall.

I want to have a list of partner into my module.

all the xml code is in view/views.xml file

so I create my menu item :
    <menuitem name="MyModule" id="menu_root_videomeeting" groups="base.group_user"/>
    <!--Student submenu-->
    <menuitem name="Contacts" id="menu_contacts" parent="menu_root_mymodule"/>
    <menuitem name="List" id="menu_contact_list" parent="menu_contacts" action="action_contact_list"/>

 

I have an action :
    <record id="action_contact_list" model="ir.actions.act_window">
      <field name='name'>Contacts list</field>
      <field name='type'>ir.actions.act_window</field>
      <field name='res_model'>res.partner</field>
      <field name='view_type'>form</field>
      <field name='view_mode'>tree,form</field>
      <field name='search_view_id' ref='base.view_res_partner_filter'/>
    </record>

 

And I have the two view tree, form:

    <record id="action_contacts_view_tree" model='ir.actions.act_window.view'>
      <field name="sequence" eval="1"/>
      <field name="view_mode">tree</field>
      <field name="view_id" ref="base.view_partner_tree"/>
      <field name="act_window_id" ref="action_contact_list"/>
      <field name="arch" type="xml">
          <field name="email" position="before">
              <field name="city"/>
          </field>
      </field>
    </record>


    <record id="action_contacts_view_form" model='ir.actions.act_window.view'>
      <field name="sequence" eval="1"/>
      <field name="view_mode">form</field>
      <field name="view_id" ref="base.view_partner_form"/>
      <field name="act_window_id" ref="action_contact_list"/>
    </record>

 

And the field city in the tree view is not display.

I try to add in my __openerp__.py:
    'update_xml': ['view/views.xml',],

do nothind and after
    'data': ['view/views.xml',],

 

How can i only add one field in my view which is already exist in the res_partner model ?

Thanks.

 

0
Kazim Mirza
On 5/16/14, 12:57 AM

you can simply add field in _columns of your class

like this,

'name' : fields.many2one('res.partner','Employee')

you can use other res.partner field like this 

0
0
clement zotti
On 5/16/14, 11:05 AM

I solve my problem with the following information:

My python file is :
class my_module(osv.Model):
    _name = 'res.partner'
    _inherit = 'res.partner'
    _columns = {
            'pfield': fields.char('MyField', size=10)
            }

my_module()

 

my view xml is :


        <record id="my_module_view_tree" model="ir.ui.view">
            <field name="name">my.module.inherit.tree</field>
            <field name="model">res.partner</field>
            <field name="priority" eval="20"/>
            <field name="arch" type="xml">
                <tree string="Contacts List" create="false" delete="false">
                    <field name="name"/>
                    <field name="user_id" invisible="1"/>
                    <field name="country_id" invisible="1"/>
                    <field name="parent_id" invisible="1"/>
                    <field name="company_id" />
                    <field name="email"/>
                    <field name="pfield"/>
                </tree>
            </field>
        </record>

for select only the field i need to display

and


        <record id="action_contacts_view_tree" model='ir.actions.act_window.view'>
            <field name="sequence" eval="1"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="my_module_view_tree"/>
            <field name="act_window_id" ref="action_contact_list"/>
        </record>


to display it when i click on my button

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: 5/15/14, 5:06 PM
Seen: 2618 times
Last updated: 3/16/15, 8:10 AM