Skip to Content
Menu
This question has been flagged
2 Replies
7031 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.

https://www.odoo.com/nl_NL/groups/community-framework-62/community-framework-16152974?mode=thread&date_begin=&date_end=

Avatar
Discard
Author Best Answer

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

https://www.odoo.com/nl_NL/groups/community-framework-62/community-framework-16152974?mode=thread&date_begin=&date_end=  

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 }

Avatar
Discard
Best Answer

Hi, i had the same issue!

well the solution is add flags= {'action_buttons': True}

flags = {'action_buttons': True}
 return {
  'name':'Suppliers',
  'view_mode': 'form',
  'view_type': 'form',
  'views':[(False, 'form')],
  'res_model': 'res.partner',
  'type': 'ir.actions.act_window',
  'view_id': view_id,
  'target': 'new',
  'context': context,
  'flags': flags,
  }

hope this help you!

Avatar
Discard
Related Posts Replies Views Activity
2
Dec 22
14255
1
Nov 21
4386
0
Jan 21
1924
8
May 20
7318
0
Dec 23
2643