İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
8308 Görünümler

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
Vazgeç
En İyi Yanıt

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
Vazgeç
Üretici

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

Üretici

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

Üretici

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

En İyi Yanıt

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Tem 18
7753
2
Haz 22
2568
3
Kas 19
18080
2
Tem 18
10013
0
Tem 17
4223