how to show archived task in many2many tree view on another model in Odoo9?

1.1k views Asked by At

I'm trying to show the archived tasks (active = False) beside of the active tasks on many2many field view (Project Management Module) on Odoo9.

Ok, for a moment i just trying to show the archived tasks (active = False) only, so i've tried this code on my form view xml:

<field name="task_ids" widget="one2many_list" mode="tree" domain="[('active', '=', False)]"/>

OR

<field name="task_ids" widget="one2many_list" mode="tree" context="{'active_test': False,}"/>

But, still not working. The field 'task_ids' is still showing only the active tasks.

2

There are 2 answers

0
Yannick On BEST ANSWER

Odoo 9.0

Here you will have to override the field. Change the domain of your field in a python file in your module.

task_ids = fields.Many2many(
        domain=['|', ('active', '=', False), ('active', '=', True)])

Trying to use active_test on Many2many won't work.

Plus, note that [('active', 'in', [True, False])] won't work either. Because, whene the automatic active test is made, it will check if ('active', '=', False) is present. If not, it adds ('active', '=', True) to filter all archived items by default.

1
Chandni On

You should put this domain instead of that:

<field name="task_ids" widget="one2many_list" mode="tree" domain="[('active', '=', True)]"/>

It will give u the active tasks only. ALso check whether that field is there or not. It is there by default but still sometimes we have to check is database in particular object.

Hopw this will help you.

Thanks, Chandni.