summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/basic_model_tests.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-08-11 08:46:11 +0200
committerAaron Bohy <aab@odoo.com>2017-08-11 10:28:12 +0200
commit870aa81ad9ef26b88bff8190a71e8c805fe33beb (patch)
treef97cbe1e7d197ac96152c96e0d760293744f9f4f /addons/web/static/tests/views/basic_model_tests.js
parent3b7fb9934d795ff6971727089e6bbe0a77c06476 (diff)
[FIX] web: BasicModel: default_get: handle false value for o2m
The value for one2many fields returned by default_get may be a list of commands, or directly a list of ids. These cases were correctly handled. However, it seems that the value can also be false, and when this happened, it crashed. For instance, go to Sales > Leads (must be activated in the Settings) > in the list view, check several leads > in 'Action', click on 'Convert to Opportunities' > crash.
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
-rw-r--r--addons/web/static/tests/views/basic_model_tests.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/basic_model_tests.js b/addons/web/static/tests/views/basic_model_tests.js
index 8c23fc4f97c..98f895969a4 100644
--- a/addons/web/static/tests/views/basic_model_tests.js
+++ b/addons/web/static/tests/views/basic_model_tests.js
@@ -2007,5 +2007,25 @@ QUnit.module('Views', {
model.destroy();
});
+ QUnit.test('default_get with value false for a one2many', function (assert) {
+ assert.expect(1);
+
+ this.data.partner.fields.product_ids.default = false;
+ this.params.fieldNames = ['product_ids'];
+ this.params.res_id = undefined;
+ this.params.type = 'record';
+
+ var model = createModel({
+ Model: BasicModel,
+ data: this.data,
+ });
+
+ model.load(this.params).then(function (resultID) {
+ var record = model.get(resultID);
+ assert.deepEqual(record.data.product_ids.data, [], "o2m default should be []");
+ });
+
+ model.destroy();
+ });
});});