To avoid that behavior I only know how to do it by going into the JS way to avoid the default behavior that makes the record saves and validation when leaving the current record with changes
But that it's the hard way because you need to do everything by yourself and that way you need to know what are you doing and how to do it.
Take this as an starting point code, it contains 3 ways to get it:
var o2m_list_view_ext = false;
FieldOne2Many.include({
init: function() {
this._super.apply(this, arguments);
if(o2m_list_view_ext == false){
o2m_list_view_ext = true;
var One2ManyListView = this.x2many_views.list;
One2ManyListView.include({
do_button_action: function (name, id, callback) {
var self = this;
var action = _.detect(this.columns, function (field) {
return field.name === name;
});
if(action.widget != undefined && action.widget == 'your_custom_button_widget'){
// call your js code here
// ...
// or
// call the normal button action without restrictions like:
// ...
// self.handle_button(name, id, callback);
// or if the view need to be reloaded:
// ...
// self.handle_button(name, id, function(){
// self.x2m.view.reload();
// });
} else {
this._super(name, id, callback);
}
}
});
}
}
});
After that you only need to define a button using the expected widget
Hope this helps