[FIX] web: avoid force_reload in list editable
When creating a new record in list editable, due to previous commit 6349048
, the load_record was called twice and the first record of the current list view (self.dataset.index) was used to fill the new record.
With this, we make sure a new record is indeed created.
Fix the web test to have a default_get call in mock models and increase the number of default_get assertions (for creations in list editable, the default_get is then called twice, not optimal but due to the absence of distinction between empty datarecord and filled with default values).
This commit is contained in:
parent
6349048ba0
commit
cb30783aba
|
@ -284,7 +284,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
var shown = this.has_been_loaded;
|
var shown = this.has_been_loaded;
|
||||||
if (options.reload !== false || !this.datarecord.id) {
|
if (options.reload !== false || !this.datarecord.id) {
|
||||||
shown = shown.then(function() {
|
shown = shown.then(function() {
|
||||||
if (self.dataset.index === null) {
|
if (self.dataset.index === null || !self.datarecord.id) {
|
||||||
// null index means we should start a new record
|
// null index means we should start a new record
|
||||||
return self.on_button_new();
|
return self.on_button_new();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@ openerp.testing.section('editor', {
|
||||||
mock('test.model:onchange', function () {
|
mock('test.model:onchange', function () {
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
|
mock('test.model:default_get', function () {
|
||||||
|
return {};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, function (test) {
|
}, function (test) {
|
||||||
/**
|
/**
|
||||||
|
@ -211,7 +214,7 @@ openerp.testing.section('list.edition', {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, function (test) {
|
}, function (test) {
|
||||||
test('newrecord', {asserts: 6}, function (instance, $fix, mock) {
|
test('newrecord', {asserts: 7}, function (instance, $fix, mock) {
|
||||||
var got_defaults = false;
|
var got_defaults = false;
|
||||||
mock('demo:default_get', function (args) {
|
mock('demo:default_get', function (args) {
|
||||||
var fields = args[0];
|
var fields = args[0];
|
||||||
|
|
Loading…
Reference in New Issue