Odoo Help


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


[ODOO8] Show save/cancel button in new window-action

on 1/22/16, 4:00 AM 544 views

Hello fellow odooers

I have a module which calls a method, this method returns a window-action of sale.order's default form-view. The target I use is 'new'. The sale_order gets opened in an editable window, but no button (save/cancel) shows up. The button confirm order, send order etc shows up, but I do not need those buttons at this stage. I'd just like to be able to save my sale_order in the state that I edited it.

Another option for me would be to use the target 'current', but then my new sale_order would not be in edit mode. I have been looking in web's view_form.js and found the method 'to_edit_mode', but I am unsure on how to implement it in my python code to be able to start the view in edit-mode

The option 'inline' also starts in edit mode, but does not show the save/cancel buttons either.

Any help on this would be greatly appreciated.

EDIT: I have tried to install a module referenced in this topic: https://www.odoo.com/fr_FR/forum/help-1/question/closed-open-a-form-in-a-specified-state-edit-browse-3447 , But this module does not do anything. I have tried printing in the beginning of this js file, but with no luck.

So currently I have 3 options: 
1) Use target: new, which opens a wizard-like window in edit mode, without the option to save.
2) Use target: inline, which opens a form-view in edit mode, without the option to save.
3) Use target: current, which opens a form-view in view-mode, so I would have to click 'Edit'

The last option is preferred, but it would be perfect if this view could be opened in edit-mode. I tried adding the class oe_form_button_edit to my button (this class triggers edit-mode on click) but am unable to start my view in edit mode.

EDIT2: #openobject at freenode mentioned that a similar question was asked on the mailing list, so I started digging here and found a possible solution. I haven't had the time to figure it out, but I will try this soon and update this post.


On 1/22/16, 8:22 AM

The answer on how to open a wizard or a window-action in edit mode:


This link references an example where the dictionary 'flags' is passed in the result-dictionary. After adding this to my return-statement, the view opens in edit mode! Hurray

flags = {'initial_mode': 'edit'}

return {     'type': 'ir.actions.act_window',     'view_type': 'form',     'view_mode': 'form,tree',     'res_model': 'sale.order',     'res_id': new_order.id,     'context': ctx,     'target': 'current',     'flags': flags,     # optionally, you could refine by specifying 'views' explicitly. False means 'use default view for model'     'views': [(False, 'form'), # open default form view first,               (False, 'tree')] # then default tree view }

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 1/22/16, 4:00 AM
Seen: 544 times
Last updated: 1/22/16, 8:22 AM