Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

How do I change the columns displayed in a many2many tree view?

Subscribe

Get notified when there's activity on this post

This question has been flagged
treeviewv7treemany2many
3 Replies
55568 Views
Avatar
AJ Schrafel Paper Corp

I have a custom module with a tree view that display a many2many field. Everything works fine, i would just like to display different fields in the tree view.

This is the pertinant part of the code

<group>
    <tree string="Partner Contacts">
        <field name="partner_id" domain="[('customer','=',True),('opt_out','=',False)]"/>
    </tree>
</group>

Using the above XML code, the tree view displays the columns Name, Phone, Email.

How can I modify it so that the columns display are Name, City, State?

Thanks.

1
Avatar
Discard
Avatar
AJ Schrafel Paper Corp
Author Best Answer

I fixed it by doing the following:

<group>
<field name="partner_id" widget="many2many">
   <tree>
      <field name="name"/>
      <field name="city"/>
      <field name="state"/>
   </tree>
</field>
</group>
13
Avatar
Discard
Jérôme Thériault

Still works in Odoo 10

mitra safari

<field name="partner_id" widget="many2many_tags">

in odoo 11

Avatar
Lucas
Best Answer

You may define a custom tree view with the fields you want to show and explicitly use it for your many2many field

doc.openerp.com/v6.0/developer/2_6_views_events/views/specify_view_to_use.html

<field name="order_line" colspan="4" nolabel="1" context="{'form_view_ref' : 'module.view_id', 'tree_view_ref' : model.view_id'}"/>

where 'tree_view_ref' points to your custom tree view

2
Avatar
Discard
Avatar
klacus
Best Answer

Please check this sample. The model has a many2one field. This many2one is Calib_id. This is a connection with a two table. csyscmeascalibrate >> csyscmeascalibraterow. You can use this way to see what you want, and filter the data if is it necessary.

Xml.:

        <record model="ir.ui.view" id="csysc_measuringtoolcalibration_form_view">   
        <field name="name">csysc_measuringtoolcalibration.form</field>
        <field name="model">csyscmeascalibrate</field>
        <field name="type">form</field>       
        <field name="arch" type="xml">
        <form string="Measuring Equipment Calibration Plan">
                <group colspan="4" col="6">                                 
                <field name="name"/>     
                <field name="Title"/>
                <field name="ISO_form_number"/>
                <field name="type"/>    
                </group>  
                                <notebook colspan="4">
                                    <page string="Controlled Calibration points">
                                     <field colspan="4" name="Calib_lines" nolabel="1" widget="one2many_list" mode="tree"/>                                                                                                 
                                    </page>
                                </notebook>         


            </form>             
        </field>
    </record>

python

class csyscmeascalibraterow(osv.osv):
_name = "csyscmeascalibraterow"
_description = "calibration data sheet"
_columns = {    
    'name'  : fields.char('Calibration point:',size=40, required = True, help='The name of the calibration point, like jig width or ring diameter...etc'),
    'Calib_id':fields.many2one('csyscmeascalibrate','Parent Calibration', select=False, ondelete='cascade'),
    'NomValue' : fields.float('Nominal Value:',size=40, required = False, help='Nominal measuring value: like 12.00'),
    "Max_deviation" : fields.char('Max deviation:',size=40, required = False, help='Maximum deviation from nominal measuring value: like 12.00'),
    }
csyscmeascalibraterow() 


class csyscmeascalibrate(osv.osv):
_name = "csyscmeascalibrate"
_description = "calibration data sheet"
_columns = {
    'name'  : fields.char('Calibration Name:',size=40, required = True, help='The name of the calibration like Calipper 0-150...etc'),
    'Title'     : fields.char('Calibration title:',size=40, required = True, help='Title of the calibration point, like measuring series with jig...'),     
    'ISO_form_number' : fields.char('Iso Form Number:',size=40, required = False, help='The ISO system form number'),
    'type': fields.many2one('csyscmtooltypes','Equipment type',required = True),
    'Calibration_child_row_id': fields.many2one('csyscmeascalibrate','csyscmeascalibrate'),
    'Calib_lines': fields.one2many('csyscmeascalibraterow', 'Calib_id', 'Calibration Plan id'),  
        }
csyscmeascalibrate()
-1
Avatar
Discard
AJ Schrafel Paper Corp
Author

thank you for your comment, but how does this change the columns automatically displayed when a many2many field is displayed?

klacus

As I think this is depend the relation. Please put it your code, and the situation will be clear, what you want...

Lucas

klacus, your example does not customize the fields you want to show within the nested tree view

klacus

Yes because this is show all of the fields from csyscmeascalibraterow. If you want to show a special view, you must declare it in xml, and after that you need to call according by tree name. (As I know :-) )

Lucas

"i would just like to display different fields in the tree view.", that's the key part

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Show a field from many2many relationship in a tree view Solved
treeview tree many2many tree_view
Avatar
Avatar
Avatar
Avatar
4
Jun 25
12375
Multi step wizard with data from many2many relation?
v7 many2many
Avatar
0
Mar 15
7676
xml-rpc search on many2many query
v7 many2many
Avatar
Avatar
Avatar
2
Mar 15
10292
Highlight Records in Tree Solved
treeview tree odoo
Avatar
Avatar
Avatar
Avatar
3
May 23
2900
How to hide import button in a specific tree view in Odoo v12
import treeview tree
Avatar
Avatar
1
Apr 23
4581
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now