Odoo opens the form view with do_action, and when target is current, it goes directly to the editing interface

Today, there is a need for the merged delivery function in the previous blog. Click on the merged delivery button to reach the form view of the logistics list. At this time, the logistics list is temporarily saved, which requires users to complete the logistics data on the logistics list. At this time, users need to click the Edit button again, enter the editing state, and edit the data needed for the logistics order. But the requirement of the product is that after the logistics list is generated, the display interface is temporarily saved edit status interface, which was intended to be objected to, because it has not been done before, it needs to modify the js framework to achieve that effect. Ultimately, I tried to modify it as required by the product.
Through hard work, we finally achieved the effect of that demand. When do_action opens the form view of the logistics sheet, target is set to current, flags parameter is added, set to'form': {action_buttons': true,'options': {mode':'edit'}. The overall code is as follows:
self.do_action({
                        name: ctx['name'],
                        type: 'ir.actions.act_window',
                        res_model: 'logistics.bill',
                        view_mode: 'form',
                        view_type: 'form',
                        views: [[false, 'form']],
                        target: 'current',
                        res_id: res_id,
                        flags: {'form': {'action_buttons': true, 'options': {'mode': 'edit'}}},
                        context: ctx,
                        params: {
                            model: self.dataset.model,
                            // self.dataset.get_context() could be a compound?
                            // not sure. action's context should be evaluated
                            // so safer bet. Odd that timezone & al in it
                            // though
                            context: self.getParent().action.context,
                        }
                        }, {
                            on_reverse_breadcrumb: function () {
                                self.reload();
                            },
                            on_close: function () {
                                self.reload();
                            }
                        });




Hope to be helpful to the students who have this need!

Posted by finger on Thu, 07 Feb 2019 19:18:17 -0800