Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
13559 Visualizações

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?

Avatar
Cancelar
Melhor resposta

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.


Rgds,

Anil.


Avatar
Cancelar
Autor

Thank you! Overriding search method worked.

Melhor resposta

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.

Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
2
mar. 24
11348
5
ago. 20
7508
1
dez. 19
5403
0
set. 17
3553
0
ago. 17
2900