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

show filtered records in one2many field using Domain

Subscribe

Get notified when there's activity on this post

This question has been flagged
domainone2manyv7x2many
3 Replies
27120 Views
Avatar
Shaumyadeep Chaudhuri

Hi, Can i show only selected records in a one2many field using a domain, I have tried this

<field name="func_details_inno" nolabel="1" context="{'functional_dep' : 'Innovation'}" domain="[('functional_dep','=','Innovation')]">

where func_details_inno is a one2many field with functional_dep a char field in the model for func_details_inno

How can i do it?

0
Avatar
Discard
Xsias

You haven't closed the balise "/>". This is wanted ?

Shaumyadeep Chaudhuri
Author

Yes this is wanted and intentional, i'm defining the tree view and the form view inside for the one2many field, something like <field name="func_details_inno" nolabel="1" context="{'functional_dep' : 'Innovation'}" domain="[('functional_dep','=','Innovation')]"><tree>...</tree><form>...</form></field>

Xsias

This is what i was thinking, but now i'm sure. Can you, for clarify, put all the field in the question please ?

Shaumyadeep Chaudhuri
Author

Its a bit long i have pastebinned the most relevant part of it and here is the link http://pastebin.com/PJqY6uwk Hope that helps to solve the problem

Avatar
Xsias
Best Answer

Add :

<field name="functional_dep" invisible="True"/>

In the tree view of the "func_details_inno" field like that :

<tree>
    <!-- <field name="activity">
    <tree>
    <field name="activities"/>
    <field name="person"/>
    <field name="start"/>
    <field name="end"/>
    </tree>
    </field> -->
    <field name="functional_dep" invisible="True"/>
    <field name="activity"/>
    <field name="yes"/>
    <field name="no"/>
    <field name="na"/>
    <field name="reason" />
    <field name="risks" />
</tree>
1
Avatar
Discard
Shaumyadeep Chaudhuri
Author

Thanks for your reply but the problem is not that i want to hide a particular column, it can simply be achieved by not including the field in the tree view at all. The problem is i want to filter rows in the tree view and hence the requirement for using domains

Xsias

Yes, but in my memories, if you want to filter on a field, you need to have this field in the tree view.

Shaumyadeep Chaudhuri
Author

the functional_dep field is already there and it doesn't need to be invisible, i want to show only those rows which belong to a particular functional field, innovation in this case, there might be other records in the table which have some other functional_dep value

Xsias

functional_dep field is not in the tree. (not in the code you post on pastebin)

Shaumyadeep Chaudhuri
Author

oh sorry, i had added it later after posting it. but it doesn't help

Xsias

Ok, can you post again your code on pastebin ? (To have the latest version)

Shaumyadeep Chaudhuri
Author

yes sure, but theere aren't many big changes, here's the code http://pastebin.com/uVEReG7P

Avatar
Timo Talvitie, Vizucom Oy
Best Answer

This post at Launchpad discusses the issue, but it doesn't make it clear whether it is really a bug or simply by design. I had the same issue and tried two possible solutions:

1) Change the field to many2many if you have control over the field types. Domain filtering works fine with m2m fields, or

2) Follow this post by Andreas Brueckl that shows a way to do o2m filtering with a functional field and its fnct_inv parameter

They both worked, but converting relationships that clearly should be o2m to m2m just to get access to filtering functionality feels a bit wrong, so I ended up using solution #2.

0
Avatar
Discard
Avatar
Purnendu Singh (psi)
Best Answer

class one2many_mod2(fields.one2many):

def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
    if context is None:
        context = {}
    if not values:
        values = {}
    res = {}
    for id in ids:
        res[id] = []
    ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',ids),('state', '=', 'open')], limit=self._limit)
    for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
        res[r[self._fields_id]].append( r['id'] )
    return res

class res_partner(osv.osv):

_inherit = 'res.partner'
_columns = {
    'partner_scheduled_calls': one2many_mod2('crm.phonecall', 'partner_id', 'Scheduled Calls', ),

}

this will filter the scheduled calls(('state', '=', 'open')) only from all call logs.

Hope this will help

0
Avatar
Discard
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
How to Set Fixed Filter for a User / User group ?
domain v7
Avatar
Avatar
1
Aug 15
6645
limited choose list depented on another
domain one2many
Avatar
Avatar
1
Jun 15
4672
On_change domain on one2many field
domain one2many
Avatar
Avatar
2
Jun 15
4338
V 7 - One2Many form view
one2many v7
Avatar
0
Mar 15
3701
domain on a field in computed one2many
domain one2many computed-fields
Avatar
0
Sep 24
1928
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