Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
12 Trả lời
25317 Lượt xem

When opening a form from an function returning an action code as in the example below, I was wondering how could I explicitly specify the state of the form, wether it's in edit or browse mode ?

'type': "ir.actions.act_window"
'res_model': 'model'
'view_type': 'form'
'view_mode': 'form'
'target': 'current'
'context': context

I noticed the following:

  • 'target' = 'new'opens in edit mode (as when creating wizards..)
  • 'target' = 'current' opens in browse mode (as in regular form views)
  • context does not seem to contain any specific instructions

Thanks for your time. Nicolas

Ảnh đại diện
Huỷ bỏ
Tác giả

Works ! Thanks for saving me hours ))

@Nicolas: please mark the answer as correct (below the vote). Also, I converted your thanks to a comment (I couldn't move it under the answer though), because that's not an answer, only real answer should be posted as such.

Câu trả lời hay nhất

You can set 'target' = 'inline'. This opens a form in edit mode.

Ảnh đại diện
Huỷ bỏ

Also needed this, thank you!

Andreas, when returning an action that has 'target' = 'inline' in the case of the sale.order it indeed opens it in edit mode but the top menu (Create, Edit, Save,Print, More) disapears alltogether.Do you have any idea why that happens and how to prevent it?

This solution is not valid, because the top menus disappear from view. Is there any other way? thanks in advance.

me too, i've tried to look at base/ir/ir_actions.py but still get stucked.

Câu trả lời hay nhất

Found this way in calendar module and it works fine :-)

Add following key into the action dict:

'flags': {'form': {'action_buttons': True, 'options': {'mode': 'edit'}}},
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Just add the dictionnary flags like that and you will get buttons save/cancel and the form in edit mode:

'flags': {'initial_mode': 'edit'},

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

On Odoo 11, and from javascript, add this to the object:

context: {'form_view_initial_mode': 'edit','force_detailed_view': true},


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

I developped this module to achieve that.  install it and use 'target' : 'current_edit' to open form in edit mode 

Ảnh đại diện
Huỷ bỏ

Hi, I install your module but I have this error: except_orm: (u'ValidateError', u'The value "current_edit" for the field "ir_act_window.target" is not in the selection') Can you help me?

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 2 25
790
2
thg 3 15
11936
0
thg 3 25
780
1
thg 2 24
6109
2
thg 12 22
3064