Fix action button sensibility

Allow to run action if no record is selected.

issue3685
review3611004
This commit is contained in:
Cédric Krier committed 2014-02-20 23:36:38 +01:00
1 parent 843c750f61
commit 242d237868
3 files changed
+27 -15

No files matched your search

+1 -1
View File
@@ -37,7 +37,7 @@
}
var ctx = {
active_model: data.res_model,
active_id: data.id || false,
active_id: data.id || null,
active_ids: data.ids
};
var session = Sao.Session.current_session;
+6 -3
View File
@@ -446,9 +446,8 @@
if ((this.current_view.view_type == 'tree') &&
(!jQuery.isEmptyObject(this.group))) {
this.set_current_record(this.group[0]);
} else {
return true;
}
return jQuery.when();
}
this.current_view.set_value();
var fields = this.current_view.get_fields();
@@ -689,8 +688,12 @@
this.display();
},
get_buttons: function() {
var selected_records = this.current_view.selected_records();
if (jQuery.isEmptyObject(selected_records)) {
return [];
}
var buttons = this.current_view.get_buttons();
this.current_view.selected_records().forEach(function(record) {
selected_records.forEach(function(record) {
buttons = buttons.filter(function(button) {
var states = record.expr_eval(
button.attributes.states || {});
+20 -11
View File
@@ -307,17 +307,26 @@
jQuery('<a/>').append(action.name));
menu.append(item);
item.click(function() {
var exec_action = jQuery.extend({}, action);
// TODO test save
exec_action = Sao.Action.evaluate(exec_action,
menu_action[0], screen.current_record);
var data = {
model: screen.model_name,
id: screen.get_id(),
ids: [screen.get_id()] // TODO ids selected
};
Sao.Action.exec_action(exec_action, data,
screen.context);
screen.save_current().then(function() {
var exec_action = jQuery.extend({}, action);
var record_id = null;
if (screen.current_record) {
record_id = screen.current_record.id;
}
var record_ids = screen.current_view
.selected_records().map(function(record) {
return record.id;
});
exec_action = Sao.Action.evaluate(exec_action,
menu_action[0], screen.current_record);
var data = {
model: screen.model_name,
id: record_id,
ids: record_ids
};
Sao.Action.exec_action(exec_action, data,
screen.context);
});
});
});
menu.menu({}).hide().css({