summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/basic_model_tests.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-04-13 10:21:48 +0200
committerAaron Bohy <aab@odoo.com>2017-04-13 14:31:24 +0200
commit6b936ba2030e1cb3c6abdaf7f9486afde4ef49ef (patch)
tree6d8a0722c15b496af10f204beb2cbc3fa684d005 /addons/web/static/tests/views/basic_model_tests.js
parentfce45c3361ac55292fc545bdf17b33e37a3dd242 (diff)
[FIX] web: correctly save many2manys inside one2manys
In a form view, if a one2many list view contained a many2many field (e.g. widget many2many_tags), the commands for the embedded many2many weren't generated for newly created one2many subrecords, so this field couldn't be saved.
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, 12 insertions, 8 deletions
diff --git a/addons/web/static/tests/views/basic_model_tests.js b/addons/web/static/tests/views/basic_model_tests.js
index 15947103e6e..a81c4a13602 100644
--- a/addons/web/static/tests/views/basic_model_tests.js
+++ b/addons/web/static/tests/views/basic_model_tests.js
@@ -775,6 +775,13 @@ QUnit.module('Views', {
this.params.res_id = undefined;
this.params.type = 'record';
+ var o2mRecordParams = {
+ fields: this.data.product.fields,
+ fieldNames: ['name'],
+ modelName: 'product',
+ type: 'record',
+ };
+
var model = createModel({
Model: BasicModel,
data: this.data,
@@ -788,18 +795,15 @@ QUnit.module('Views', {
});
model.load(this.params).then(function (resultID) {
-
var record = model.get(resultID);
assert.strictEqual(record.data.product_ids.data.length, 0,
"one2many should start with a list of length 0");
- model.makeRecord('product', [{
- name: 'name',
- string: "Product Name",
- type: "char",
- value: "xpod"
- }
- ]).then(function (relatedRecordID) {
+ // make a default record for the related model
+ model.load(o2mRecordParams).then(function (relatedRecordID) {
+ // update the subrecord
+ model.notifyChanges(relatedRecordID, {name: 'xpod'});
+ // add the subrecord to the o2m of the main record
model.notifyChanges(resultID, {
product_ids: {operation: "ADD", id: relatedRecordID}
});