diff --git a/src/common.js b/src/common.js index 5e2d10e238..c752e6d23f 100644 --- a/src/common.js +++ b/src/common.js @@ -694,7 +694,8 @@ } this.el.prop('disabled', states.readonly); this.set_icon(states.icon || this.attributes.icon); - if (record) { + if (((this.attributes.type === undefined) || + (this.attributes.type === 'class')) && (record)) { var parent = record.group.parent; while (parent) { if (parent.has_changed()) { diff --git a/src/screen.js b/src/screen.js index 50f9fa5231..bae73e1680 100644 --- a/src/screen.js +++ b/src/screen.js @@ -1142,6 +1142,9 @@ if (record.group.get_readonly() || record.readonly) { return false; } + if (button.attributes.type === 'instance') { + return false; + } var states = record.expr_eval( button.attributes.states || {}); return !(states.invisible || states.readonly); @@ -1203,18 +1206,31 @@ return; } - var context = jQuery.extend(this.context); - context._timestamp = {}; - for (i = 0; i < selected_records.length; i++) { - record = selected_records[i]; - jQuery.extend(context, record.get_timestamp()); - } // TODO confirm - this.current_record.save().done(function() { - this.current_record.model.execute(attributes.name, - [ids], context).then(process_action.bind(this)) - .then(reload_ids); - }.bind(this)); + var record = this.current_record; + if (attributes.type === 'instance') { + var args = record.expr_eval(attributes.change || []); + var values = record._get_on_change_args(args); + record.model.execute(attributes.name, [values], this.context) + .then(function(changes) { + record.set_on_change(changes); + record.group.root_group().screens.forEach(function(screen) { + screen.display(); + }); + }); + } else { + var context = jQuery.extend(this.context); + context._timestamp = {}; + for (i = 0; i < selected_records.length; i++) { + record = selected_records[i]; + jQuery.extend(context, record.get_timestamp()); + } + record.save().done(function() { + record.model.execute(attributes.name, + [ids], context).then(process_action.bind(this)) + .then(reload_ids); + }.bind(this)); + } }.bind(this)); }, client_action: function(action) {