Tree view, how to force filtering

Asked by Olivier Lenoir

When you have large tables with thousands of rows it has often no sense to list anything without any filter. There is no use to list the first 20 or more rows because the user will have to set a filter. Is-it possible to force one value in one ore more filters before any display or to wait a filter from the user ?

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Olivier Lenoir
Solved:
Last query:
Last reply:
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) said :
#1

Hi Olivier,

You may set domain/filter on the action of the menuitem to have FILTERED records of that table.

You may do this from GUI.

It looks like you are using web-client. Have a focus on the menuitem, click on SWITCH. You will see the form view of Menu.
You will see an action linked to that menu under 'ACTION:' Click on the First button of that Many2one Action.

Apply / Edit the domain.

This will serve your purpose.

Thanks.

Revision history for this message
Olivier Lenoir (olivier-lenoir-free) said :
#2

Hi Jay,
Thanks for this answer, we are going to test this asap but we need to put it in the code because the conditions may vary according to the user and the tree in our modules.
Some news later about ...

Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) said :
#3

Hi Olivier,

You need to change the tree view by adding domain for particular field in .xml file by following way:

<field domain="<your side domain>" name="<field name>"/>

Hope this will help you.

Thanks.

Revision history for this message
Olivier Lenoir (olivier-lenoir-free) said :
#4

Hi,

This could help but tell-me some examples about how we can use
<your side domain>

Thanks

Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) said :
#5

Hi Olivier,

For example : related view with id view_account_analytic_line_tree exist in account/project/project_view.xml file.
<field domain="[('type','=','normal')]" name="account_id"/>
account_id is many2one field of account.analytic.account relation, so it will show or allow you only those analytic account which has a type 'normal'.

Hope now you will understand what i wanted to tell you.
Thanks.

Revision history for this message
Olivier Lenoir (olivier-lenoir-free) said :
#6

Wow, speedy vra !

Many thanks for this very fast reply...
I think possible to close here my question

I'll post new questions a bit close to this one.

Thanks again
Olivier