[FIX] do not break dataset index (at the wrong moment) when clicking on [Create] row
dataset.index was previously set to ``null`` in handler of [Create] button (to fullfill contract with form view that dataset.index should be ``null`` to indicate the creation of a new record with no id). Issue: after setting the index to ``null``, the list view calls ``render_row_as_form`` which starts out trying to save a row being edited (case: clicking of the [Create] button after having selected a row for edition or after having written in a new record e.g. [Create] -> type -> [Create] type -> ...). This tentative to save the existing form would be performed in the context of a ``null`` dataset.index, which the form view doesn't (and shouldn't, index should be that of record *being edited*) expect. -> first save in whatever dataset state is the current one, and *right before* creating the new form (after having saved and/or discarded the previous one) we have the id of the new record to edit (or ``null``), find the index for *that* and set ``dataset.index`` to that (or ``null``) so the new form view can be created and opened in the right context. bzr revid: xmo@openerp.com-20120613153842-pd6xitjs8n003ogs
This commit is contained in:
parent
9f9bbcff33
commit
49f6ab9853
|
@ -139,6 +139,7 @@ openerp.web.list_editable = function (openerp) {
|
|||
self.edition_form.stop();
|
||||
self.edition_form.$element.remove();
|
||||
delete self.edition_form;
|
||||
self.dataset.index = null;
|
||||
delete self.edition_id;
|
||||
delete self.edition;
|
||||
});
|
||||
|
@ -232,6 +233,10 @@ openerp.web.list_editable = function (openerp) {
|
|||
}
|
||||
self.edition = true;
|
||||
self.edition_id = record_id;
|
||||
self.dataset.index = _(self.dataset.ids).indexOf(record_id) || null;
|
||||
if (self.dataset.index === -1) {
|
||||
self.dataset.index = null;
|
||||
}
|
||||
self.edition_form = _.extend(new openerp.web.ListEditableFormView(self.view, self.dataset, false), {
|
||||
form_template: 'ListView.row.form',
|
||||
registry: openerp.web.list.form.widgets,
|
||||
|
@ -360,7 +365,6 @@ openerp.web.list_editable = function (openerp) {
|
|||
[record_id, this.dataset]);
|
||||
},
|
||||
new_record: function () {
|
||||
this.dataset.index = null;
|
||||
this.render_row_as_form();
|
||||
},
|
||||
render_record: function (record) {
|
||||
|
|
Loading…
Reference in New Issue