Odoo Help


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.


Filter many2one field

John Doe
on 9/12/16, 3:28 AM 230 views


I need to filter many2one field dropdown list to show me only current year entries. I can do this by domains in xml. It works good for current year but old entries are shown in the form as unknown now.

How can i solve this?

Can you explain "but old entries are shown in the form as unknown now" a bit more?

If you put a domain (something like ('year', '>=', 2016)) in xml, old entries should not show up in the form.

Thanh Loyal
on 9/12/16, 10:28 PM

i posted a pictures

John Doe
on 9/14/16, 6:05 AM
John Doe
On 9/14/16, 2:38 AM

By this domain: <field name="timebox_id" widget="selection" options="{&quot;no_open&quot;: True}" string="Timeframe" domain="[('id','&gt;',40)]"/> it shows :

without domain:

I'd like to keep old timeframes and filter dropdown list only for this year

Divyang Jariwala
On 9/14/16, 12:31 AM

Hi John Doe,

If XML is not giving exact result as you want then,

pass a context from that field and override "name_search" method of that class and return your data based on your requirement.

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)


Asked: 9/12/16, 3:28 AM
Seen: 230 times
Last updated: 9/14/16, 2:38 AM