• Sign in
  • Try it free
    • Apps
      Finance
      • Accounting
      • Invoicing
      • Expenses
      • Spreadsheet (BI)
      • Documents
      • Sign
      Sales
      • CRM
      • Sales
      • Point of Sale
      • Subscriptions
      • Rental
      • Amazon Connector
      Websites
      • Website
      • eCommerce
      • Blogs
      • Forums
      • Live Chat
      • eLearning
      Inventory & MRP
      • 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
      • Timesheet
      • Field Service
      • Helpdesk
      • Planning
      • Appointments
      Productivity
      • Discuss
      • Approvals
      • IoT
      Third party apps Odoo Studio Odoo Cloud Platform
    • Community
      Learn
      • eLearning
      • Documentation
      • Certifications
      • Education Program
      • Scale Up! Business Game
      • Customer References
      Get the Software
      • Download
      • Compare Editions
      • Releases
      Collaborate
      • Github
      • Forum
      • Events
      • Translations
      • Become a Partner
      Get Services
      • Find a Partner
      • Find an Accountant
      • Get a Tailored 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 management
    • MRP
    Take the tour
    • All Forums
    • Topics
    • People
    • Tags
    • Badges
    • About
      Go to:
    • Question
      All Topics People Tags Badges About
    2

    Group by on field of a related model.

    Avatar
    José
    12 February 2015
    Thanks for your subscription!
    v8group_byodoo8

    Hello, I have Odoo 8.

    I need to add a "group by" button in a report. I know that the XML code is like this:

    <filter name="groupby_name" context="{'group_by': 'field''}" string="Description" />

    But I have a model A on where I do the group by and this model has a many2one relation with a model B. The attribute of the many2one relation is named "rel". If I need to group by over any field of model B, how can I do? If I write

    <filter name="groupby_name" context="{'group_by': 'rel.name_field''}" string="Description" />

    But when I press the button to grupo by I get: TypeError: this.fields[field] is undefined

    How can I do this groupby? Thanks!

    Comment Share
    Avatar
    Discard
    2 Answers
    1
    Avatar
    subbarao
    19 December 2018
    Best Answer

    Hello Jose,

    Related field field by default it will not store in the Database, so you have to pass store=True argument while declare the field on python, after that you can able to do group by.

    Comment Share
    Avatar
    Discard
    0
    Avatar
    Irfankhan Juneja
    25 February 2016
    Best Answer

    take related field:

    e.g.

    rel = fields,many2one('modelB')

    field_use_in_filter = fields.field_type(related='rel.field_name')

    and then use it in a filter 

    Comment Share
    Avatar
    Discard
    Community
    • eLearning
    • Documentation
    • Forum
    • Mailing Lists
    Open Source
    • Download
    • Github
    • Runbot
    • Translations
    Services
    • Odoo.sh Hosting
    • Support
    • Upgrade
    • Education
    • Find an Accountant
    • Find a Partner
    • Become a Partner
    About us
    • Our company
    • Contact us
    • Jobs
    • Events
    • Blog
    • Customers
    • Partners
    • Legal
    • Privacy
    • Security
    الْعَرَبيّة 简体中文 繁體中文 Nederlands English Français Deutsch Bahasa Indonesia Italiano 日本語 한국어 (KR) Português (BR) русский язык Slovenský jazyk 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

    Partner Webinar on YouTube

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

    Watch now