4

In the below code is working for form view

search_ids = self.env['sale.order'].search([])
last_id = search_ids and max(search_ids)        
return {
    'name': _('Revise Quote'),
    'view_type': 'form',
    'view_mode': 'form',
    'res_model': 'sale.order',
    'res_id': last_id.id,
    'type': 'ir.actions.act_window',
}

How to redirect to edit view?

enter image description here

Mani
  • 2,675
  • 2
  • 20
  • 42

3 Answers3

6

In the calendar module I can see they return an additional key 'flags'.

Edit: I got the chance to test it, as I received a similar task, and I can confirm that the below flags do the trick.

calendar/calendar.py

def open_after_detach_event(self, cr, uid, ids, context=None):
    ...
    return {
        'type': 'ir.actions.act_window',
        'res_model': 'calendar.event',
        'view_mode': 'form',
        'res_id': new_id,
        'target': 'current',
        'flags': {'form': {'action_buttons': True, 'options': {'mode': 'edit'}}}
    }
dgeorgiev
  • 919
  • 7
  • 22
0

I don't think that you can open edit view directly.

Edit is working in Odoo like this, when you start editing you are not editing actual record its something like virtual one (copied example of real) and after pressing save you are updating records in db.

So you cant just open edit view on virtual record using action return that's impossible using standard methods.

  • While duplicating the record its copied as well goes to edit option. Like that process anything??? – Mani Jan 09 '17 at 16:37
  • Its not clear operation for developers, odoo keeps many secrets about how it works, but anyway you can read source code and read all the information about edit functional. Good luck. But note that, using standart operations you cant achieve this and non standard ways are not recommended by odoo. So during development you must try to use standard approaches – Dachi Darchiashvili Jan 10 '17 at 09:40
0

Try this in /web/static/src/js/view_form.js (line no :116) change value of initial_mode value from view to edit. It will affect all form views.

 _.defaults(this.options, {
        "not_interactible_on_create": false,
        // "initial_mode": "view",
        "initial_mode": "edit",
        "disable_autofocus": false,
        "footer_to_buttons": false,
    });

Hope it will solve your problem.

KbiR
  • 4,047
  • 6
  • 37
  • 103