Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
4275 Переглядів

Hello.

If I filter on a one2many field to exclude one value, is the filter apply if the excluded value is not the only value of the field?

Some context:

I got a model A with a one2many field linked to the model B.

On the TreeView of the model A, I want to apply a filter to exclude each instances of model A with a link to a specific instance of model B. The domain of the filter I tried is: [('myfield.year','!=','2018')]. As `myfield` is a one2many, an instance of model A can be linked to many years.

The problem:

It work when model A had only one link to an instance of the model B, the one I want to exclude. But if an instance of model A got many link to instances of model B, with one is the one I want to exclude, the instance of model 1 still shown on the view.

Example: If one instance of model A is only linked to 2018, it is filtered. But if it is linked to 2017 and 2018, the instance of model A is not filtered

Thx for your help

Odoo version: 8.0

Аватар
Відмінити
Найкраща відповідь

I suggest you create a dynamic domain in python instead of xml. This allows you to have a better grip on the domain
Check the following links:
https://www.odoo.com/forum/help-1/question/using-function-in-domain-filter-38562
https://www.odoo.com/forum/help-1/question/odoo-11-field-with-domain-function-131942

Аватар
Відмінити
Автор Найкраща відповідь

Hi bidjo,

Have you an example of code for a dynamic domain in python?

I can't find anything in the Odoo documentation

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
жовт. 16
4370
6
серп. 15
8695
1
січ. 24
2014
1
серп. 23
23625
0
черв. 21
2819