Odoo Help


Enabling Create button from python method

Andrija Burlic
on 1/23/15, 9:31 AM 1,041 views


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,


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...

On 2/18/16, 12:10 PM

I have the same problem




| 5 4 6
Zagreb | Karlovac, Croatia

there is only 10 kind of people the ones that understand binary ... and others

On 1/26/15, 5:14 AM

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.. 

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/23/15, 9:31 AM
Seen: 1041 times
Last updated: 2/18/16, 12:10 PM