Skip to Content
Menu
This question has been flagged
3 Replies
8129 Views

Hello. I'm in a function of a wizard, I get some invoices and I want to show them as domain on the tree view "account.invoice_tree" .

I think i need to return someting like this 


window = {
'name': 'CA par adhérent',
'view_mode': 'form',
'view_type': 'tree',
# 'res_id': invoices.ids,
# 'res_id': self.id,
'res_model': 'account.invoice',
'view_id': self.env.ref('account.invoice_tree').id, #self.env.ref('account.invoice_tree').id,
'type': 'ir.actions.act_window',
'domain': [('invoice_id', 'in', invoices.ids)],
# 'target': 'self',
}


I've tried many variations but at best it shows a form view to create a new invoice
Thanks for your help
Avatar
Discard
Author Best Answer

Ok I found the solution :

return {
'name': 'CA par adhérent',
'type': 'ir.actions.act_window',
'view_mode': 'tree',
'view_type': 'form',

'res_model': 'account.invoice',
'view_id': self.env.ref('account.invoice_tree').id,
'domain': domain,
}

( I can't open it in form view but I don't need it now)

Avatar
Discard
Best Answer

Try this:

'view_mode': 'tree,form',
'view_type': 'form',

Avatar
Discard
Author

I tried and this is the error :

ValueError: Non-db action dictionaries should provide either multiple view modes or a single view mode and an optional view id.

Got view modes ['tree', 'form'] and view id 465 for action {'name': 'CA par adhérent', 'view_mode': 'tree,form', 'view_type': 'form', 'res_model': 'account.invoice', 'view_id': 465, 'type': 'ir.actions.act_window', 'domain': [('invoice_id', 'in', [])], 'flags': {}}

Try:

view_id = False

or define form id.

view_id = False

=> It's work. But I don't really understand why. Now my record are clickable and open the form

Best Answer

view_id = False

Works for me, it makes my tree view clickable and open form to edit the record

Avatar
Discard
Related Posts Replies Views Activity
0
Dec 18
3991
0
Jun 22
612
1
Aug 20
5235
0
Jul 20
2919
0
Apr 20
3373