[FIX] action buttons activated in editable o2m lists during or after row edition
bzr revid: xmo@openerp.com-20120625072046-29tg3vnnpkhj8fe9
This commit is contained in:
commit
9029f24d87
|
@ -512,7 +512,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
|
||||||
* record or saving an existing one depending on whether the record
|
* record or saving an existing one depending on whether the record
|
||||||
* already has an id property.
|
* already has an id property.
|
||||||
*
|
*
|
||||||
* @param {Function} success callback on save success
|
* @param {Function} [success] callback on save success
|
||||||
* @param {Boolean} [prepend_on_create=false] if ``do_save`` creates a new record, should that record be inserted at the start of the dataset (by default, records are added at the end)
|
* @param {Boolean} [prepend_on_create=false] if ``do_save`` creates a new record, should that record be inserted at the start of the dataset (by default, records are added at the end)
|
||||||
*/
|
*/
|
||||||
do_save: function(success, prepend_on_create) {
|
do_save: function(success, prepend_on_create) {
|
||||||
|
@ -2730,9 +2730,11 @@ openerp.web.form.One2ManyListView = openerp.web.ListView.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
do_button_action: function (name, id, callback) {
|
do_button_action: function (name, id, callback) {
|
||||||
var self = this;
|
var _super = _.bind(this._super, this);
|
||||||
var def = $.Deferred().then(callback).then(function() {self.o2m.view.reload();});
|
|
||||||
return this._super(name, id, _.bind(def.resolve, def));
|
this.o2m.view.do_save().then(function () {
|
||||||
|
_super(name, id, callback);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
openerp.web.form.One2ManyList = openerp.web.ListView.List.extend({
|
openerp.web.form.One2ManyList = openerp.web.ListView.List.extend({
|
||||||
|
@ -2743,11 +2745,24 @@ openerp.web.form.One2ManyList = openerp.web.ListView.List.extend({
|
||||||
render_row_as_form: function () {
|
render_row_as_form: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
return this._super.apply(this, arguments).then(function () {
|
return this._super.apply(this, arguments).then(function () {
|
||||||
|
// Replace the "Save Row" button with "Cancel Edition"
|
||||||
self.edition_form.$element
|
self.edition_form.$element
|
||||||
.undelegate('button.oe-edit-row-save', 'click')
|
.undelegate('button.oe-edit-row-save', 'click')
|
||||||
.delegate('button.oe-edit-row-save', 'click', function () {
|
.delegate('button.oe-edit-row-save', 'click', function () {
|
||||||
self.cancel_pending_edition();
|
self.cancel_pending_edition();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Overload execute_action on the edition form to perform a simple
|
||||||
|
// reload_record after the action is done, rather than fully
|
||||||
|
// reload the parent view (or something)
|
||||||
|
var _execute_action = self.edition_form.do_execute_action;
|
||||||
|
self.edition_form.do_execute_action = function (action, dataset, record_id, _callback) {
|
||||||
|
return _execute_action.call(this, action, dataset, record_id, function () {
|
||||||
|
self.view.reload_record(
|
||||||
|
self.view.records.get(record_id));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$(self.edition_form).bind('form-blur', function () {
|
$(self.edition_form).bind('form-blur', function () {
|
||||||
if (self.__return_blur) {
|
if (self.__return_blur) {
|
||||||
delete self.__return_blur;
|
delete self.__return_blur;
|
||||||
|
|
|
@ -487,6 +487,19 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
|
||||||
reload: function () {
|
reload: function () {
|
||||||
return this.reload_content();
|
return this.reload_content();
|
||||||
},
|
},
|
||||||
|
reload_record: function (record) {
|
||||||
|
return this.dataset.read_ids(
|
||||||
|
[record.get('id')],
|
||||||
|
_.pluck(_(this.columns).filter(function (r) {
|
||||||
|
return r.tag === 'field';
|
||||||
|
}), 'name')
|
||||||
|
).then(function (records) {
|
||||||
|
_(records[0]).each(function (value, key) {
|
||||||
|
record.set(key, value, {silent: true});
|
||||||
|
});
|
||||||
|
record.trigger('change', record);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
do_load_state: function(state, warm) {
|
do_load_state: function(state, warm) {
|
||||||
var reload = false;
|
var reload = false;
|
||||||
|
@ -1026,17 +1039,7 @@ openerp.web.ListView.List = openerp.web.Class.extend( /** @lends openerp.web.Lis
|
||||||
* @returns {$.Deferred} promise to the finalization of the reloading
|
* @returns {$.Deferred} promise to the finalization of the reloading
|
||||||
*/
|
*/
|
||||||
reload_record: function (record) {
|
reload_record: function (record) {
|
||||||
return this.dataset.read_ids(
|
return this.view.reload_record(record);
|
||||||
[record.get('id')],
|
|
||||||
_.pluck(_(this.columns).filter(function (r) {
|
|
||||||
return r.tag === 'field';
|
|
||||||
}), 'name')
|
|
||||||
).then(function (records) {
|
|
||||||
_(records[0]).each(function (value, key) {
|
|
||||||
record.set(key, value, {silent: true});
|
|
||||||
});
|
|
||||||
record.trigger('change', record);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Renders a list record to HTML
|
* Renders a list record to HTML
|
||||||
|
|
Loading…
Reference in New Issue