3

I am stuck in a problem. I want to open edit form when a button is clicked, instead of the items form that i have selected from drop down.

Edit form is opening but there is not top menu strip ribbon that has save button to save the modifications made in the form.

Setting 'target':'inline' in return of button function opened the form in edit mode.

I am not sure what i have missed. Please let me know if i am missing any attribute or something.

forvas
  • 9,801
  • 7
  • 62
  • 158
Saghir A. Khatri
  • 3,429
  • 6
  • 45
  • 76

1 Answers1

0

When you talk about a dropdown, I understand that you have a many2one field and you want to open a specific form when you click on the selected item, instead of opening the default form.

If that's what you wanted, you can do it without calling a python function, you will only need to modify the XML code:

<field name="your_many2one_field" context="{'form_view_ref': 'your_module.your_specific_form_xml_id',}"/>

Otherwise, if I didn't understand you well, try to return the next code in your python function:

return {
    'name': _('Any string you want'),
    'view_type': 'form',
    'view_mode': 'form',
    'view_id': False,
    'views': [(form_view_id, 'form'), ],
    'res_model': 'your.model',
    'type': 'ir.actions.act_window',
    'target': 'current',
    'flags': {'action_buttons': True},
}
forvas
  • 9,801
  • 7
  • 62
  • 158