This question has been flagged
2 Replies
4592 Views

Hi,

I want to add some searching functionality to my app. I made code xml and code for entering search parameters and it's all ok, except I dont have Create button in my result tree (see picture below)

I use this pice of code for showing my search results:

        return {
            'name': sql_query,
            'type': 'ir.actions.act_window',
            'view_mode': 'tree,form',
            'res_model': 'pio.request',
            'target': 'new', 
            'domain': domain,
            'nodestroy': True,
        }

http://screencast.com/t/wy6bfa7CD9

Instead that red frame I should have Create button.

In XML it should be simple- <tree create='true'...> but this is python...

How to do that?

And another thing- can someone point me towards some explanation about this 'return-parameters'. I know we have target, nodestroy, domain, view_type etc... but I don't know them all...

Avatar
Discard
Best Answer

I have the same problem

Avatar
Discard
Best Answer

1. if you want create enabled, you should use built in filters for search, and action should open view vith filters enabled by default
-give filter a name in xml, and pass it trough context in return, like: context : {search_default_filter_name : 1} 
-
use domains in your return...
 

2. if you want to use sql querry to fetch the data,
it should return list of record ids and in your return add a key: res_ids:[listo of ids]   (this aproach does not need domain!)
OR :
domain : [('id','in', [list of ids])]  

Create button is enabled by default on all editable views ( need to set create="False" to remove it!)
But in order to use it, you need to have some values in context (defining default values etc..)

as for other return values, look in action definitions inside xml files, and use all attributes found there... 

hope it helps.. 

Avatar
Discard