Odoo Help


Dynamically created filter for tree view

on 9/26/17, 5:31 AM 1,280 views

I want to make a tree view that shows only records with certain client ids which are dynamically calculated by by function. I've tried to inject these ids as a domain by overriding fields_view_get() method however to no avail.

What is the proper way to achieve this?


Anil R. Kesariya (Jupical Technologies)

--Anil R. Kesariya (Jupical Technologies)--
| 7 6 8
Rajkot, India
--Anil R. Kesariya (Jupical Technologies)--

Odoo Techno Functional Expert

* Engaged with odoo since May - 2012.

* Customise existing module or develop new module base on customer requirement.

* Played key developer role in many past and running projects.

* Expert in requirement gathering of business and transforming requirement into odoo platform.

* Major expertise in core modules, database, report development and theme development.

* Integration expert.

Linkedin  : https://in.linkedin.com/in/anil-kesariya-97b20a66

Anil R. Kesariya (Jupical Technologies)
On 9/26/17, 6:16 AM

Hi Dohn_joe,

If you want to search records on tree view dynamically on menu click

Solution 1 :  you can can override search method of the model to hit the GOAL

Solution 2 : Set default filter on search view and the comparison value of default search filter you can evaluate using compute or functional field.

Solution 3: If you want to return tree view from any method with specific domain than you can go with Avinash Solution.

I hope this would give you some idea.



Thank you! Overriding search method worked.

on 9/26/17, 7:04 AM

Avinash Nk

--Avinash Nk--

| 4 3 6
Calicut, India
--Avinash Nk--


Avinash Nk
On 9/26/17, 5:48 AM

Hi dohn_joe,

You can return the view from python like this

tree_view_ref = self.env.ref('module_name.tree_view_id', False)
form_view_ref = self.env.ref('module_name.form_view_id', False)
return {
'name': "Name of Action",
'view_mode': 'tree, form',
'view_id': False,
'view_type': 'form',
'res_model': 'your.model',
'type': 'ir.actions.act_window',
'target': 'current',
'domain': "[('id', 'in', %s)]" % record_set,
'views': [(tree_view_ref and tree_view_ref.id or False, 'tree'),
(form_view_ref and form_view_ref.id or False, 'form')],
'context': {}

You can Dynamically define the record_set variable. it can be a list of items.

Thank you.

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 9/26/17, 5:31 AM
Seen: 1280 times
Last updated: 7/3/18, 4:56 PM