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

New model many2many selection

By
Aitor Bouzas
on 1/20/15, 4:02 AM 1,370 views

Hi everyone,

I've added a new model with my custom module, and now I want to add a many2many relation field into res.company, but as I click "add" in this relation field it shows up a tree view with just one field from the new model (instead of the three componing the model...). Is there anyway to edit this popup view?

My model has just 3 fields: Postal Code (integer), City (text), Additional Description (text) and I want to show them all when you are selecting multiple values for the many2many field...

This is my actual xml view for res.company:

            <field name="arch" type="xml">
                <field name="company_registry" position="after">
                    <field name="zips_asignados" widget="many2many">
                        <tree>
                            <field name="zip"/>
                            <field name="name"/>
                        </tree>
                    </field>
                    <field name="invoicing_company" />
                </field>
            </field>

But this only shows zip and name into the res.company view, as I click "add" only "name" is showing in the new popup window...

Thanks in advice

SOLUTION:

Make a tree view for new model:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="zips_tree_view" model="ir.ui.view">
            <field name="name">zips_tree_view</field>
            <field name="model">zips</field>
            <field name="arch" type="xml">
                <tree string="Zips">
                    <field name="zip"/>
                    <field name="name"/>
                </tree>
            </field>
        </record>
    </data>
</openerp>

And reference it in the res.company view:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_company_form" model="ir.ui.view">
            <field name="name">res.company.form.inherit</field>
            <field name="model">res.company</field>
            <field name="inherit_id" ref="base.view_company_form" />
            <field name="arch" type="xml">
                <field name="company_registry" position="after">
                    <field name="zips_asignados" context="{'tree_view_ref':'zips_tree_view'}" />
                    <field name="invoicing_company" />
                </field>
            </field>
        </record>
    </data>
</openerp>

 

Can u show fields?....

Umashankar Subramani
on 1/20/15, 4:39 AM

If you mean if I can show the fields in the "add" button, then the answer is YES :)

Aitor Bouzas
on 1/20/15, 4:58 AM
4

Hardikgiri Goswami

--Hardikgiri Goswami--
1123
| 2 1 5
Rajkot, India
--Hardikgiri Goswami--

OpenERP/Odoo Customization/Integration Expert / Python Programmer

Skype ID : hardikgiri.goswami

Hardikgiri Goswami
On 1/20/15, 4:33 AM

Hello Aitor,

You need to add tree view for your new model.

<record model="ir.ui.view" id="[unique id]">
            <field name="name">name for the view</field>
            <field name="model">new.model.name</field>
            <field name="arch" type="xml">
                <tree string="">
                  <field name="name" />

                  <field name="zip" />

                  <field name="description" />
                </tree>
            </field>
        </record>

Hands down, I just needed to add a tree view like this, and make a reference to it in the res.company view. I'm editing the post to show it. Thanks!

Aitor Bouzas
on 1/20/15, 4:48 AM
1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5995
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 1/20/15, 4:30 AM

Try the following:

            <field name="arch" type="xml">
                <field name="company_registry" position="after">
                    <field name="zips_asignados" widget="many2many">
                        <tree>
                            <field name="zip"/>
                            <field name="name"/>
                        </tree>
                       <form>
                             <field name="additional_desc"/>
                             <field name="postal_code"/>
                             <field name="city"/>
                      </form>

                    </field>
                    <field name="invoicing_company" />
                </field>
            </field>

Here we have added the form view to be shown when you will click on "Add" button. It is same way as we defined 'tree' view.

Hope this helps !!.

Thanks for the anwser, but this didn't seem to work...

Aitor Bouzas
on 1/20/15, 4:47 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

1 follower(s)

Stats

Asked: 1/20/15, 4:02 AM
Seen: 1370 times
Last updated: 3/16/15, 8:10 AM