Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
8307 Ansichten

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?


Avatar
Verwerfen
Beste Antwort

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',
Avatar
Verwerfen
Autor

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

Autor

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')],

Autor

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

Beste Antwort

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',
}
Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Juli 18
7749
2
Juni 22
2565
3
Nov. 19
18075
2
Juli 18
10007
0
Juli 17
4221