How to return the form editing form in odoo?

The code below works to represent the form

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 view editing?

enter image description here

+4
source share
3 answers

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

Edit: I had the opportunity to test it, since I got a similar task, and I can confirm that the flagstrick does below .

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'}}}
    }
+3
source

I don’t think you can open editing directly.

Odoo , , , - ( ), save db.

, , return, .

0

Try this in / web / static / src / js / view _form.js (line no: 116) change the value initial_modefrom viewto edit. This will affect all kinds of forms.

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

Hope this solves your problem.

0
source

Source: https://habr.com/ru/post/1666213/


All Articles