Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
7831 Представления

Hi,

I'm trying to open a treeview from an action button. I can see the view ok but the create button doesn't work.

This is my code:

    @api.multi
def gestionar_adjuntos(self):
self.ensure_one()
empresas = self.env['empresas.onerate'].search([('vat', '=', self.vat)])
empresa_cli = empresas[0].id
result = {
'name': 'Gestionar archivos adjuntos',
'res_model': 'archivos.onerate',
'view_type': 'list',
'view_mode': 'list',
'type': 'ir.actions.act_window',
'domain': [('cliente_id', '=',empresa_cli)],
'flags': {'action_buttons': True},
'target':'main',
}
return result

What is wrong? Any idea?


Аватар
Отменить
Лучший ответ

It is because you have passed list in the view_type.

Try again by passing tree as follow:

'view_type': 'tree',
'view_mode': 'tree, form',
Аватар
Отменить
Автор

Thank you! i've already tried with this code but the view which is opened by default is the form instead of the tree

Pass your tree view in the return action as follow:

'view_id': self.env.ref('module_name.xml_id_of_tree').id

Автор

If i add the line whith the reference i get the errror:

TypeError: this.view_order[0] is undefined

I've tried too with view_id and i get the same error

ok then try with the following. I hope that will work.

tree_view_id = self.env.ref('module_name.xml_id_of_tree').id

form_view_id = self.env.ref('module_name.xml_id_of_form').id

'views': [(tree_view_id, 'tree'), (form_view_id, 'form')],

Автор

Thank you very much!! Finally I got it

The code which works is:

@api.multi

def gestionar_adjuntos(self):

self.ensure_one()

empresas = self.env['or.empresas'].search([('vat', '=', self.vat)])

empresa_cli = empresas[0].id

result = {

'name': 'Gestionar archivos adjuntos',

'res_model': 'or.archivos',

'type': 'ir.actions.act_window',

'views': [(False, 'tree'), (False, 'form')],

'domain': [('cliente_id', '=',empresa_cli)],

}

return result

Лучший ответ

You just need do below

return {
'name': _('test'),
'view_type': 'tree',
'view_mode': 'tree',
'view_id': self.env.ref('account.invoice_tree').id,
'res_model': 'account.invoice',
'context': "{'type':'out_invoice'}",
'type': 'ir.actions.act_window',
'target': 'new',
}
Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
июл. 18
7380
2
июн. 22
2105
3
нояб. 19
17539
2
июл. 18
9699
0
июл. 17
3866