summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/basic_model_tests.js
diff options
context:
space:
mode:
authorParth Gajjar <pga@openerp.com>2017-05-31 19:30:46 +0530
committerGéry Debongnie <ged@odoo.com>2017-06-01 11:26:53 +0200
commitd24ea500e6ecfdd6c3d7b10d84367d1f4b4945f9 (patch)
treedfbb69a90334b05f0fea87ea8558bfdde6d98626 /addons/web/static/tests/views/basic_model_tests.js
parenteb24f9644818f4cd18b947b3759dc126a953cf32 (diff)
[FIX] web: basicmodel: properly link parent in m2m
In some cases, the parentID was not properly set, which is a problem when we need to evaluate the parent in a context. Note: I also added a better error explanation in the mock server, to make it better for the developper to see what is wrong.
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
-rw-r--r--addons/web/static/tests/views/basic_model_tests.js34
1 files changed, 34 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 cc3834e188e..2a4b1e71349 100644
--- a/addons/web/static/tests/views/basic_model_tests.js
+++ b/addons/web/static/tests/views/basic_model_tests.js
@@ -407,6 +407,40 @@ QUnit.module('Views', {
model.destroy();
});
+ QUnit.test('many2many with ADD_M2M command and context with parent key', function (assert) {
+ assert.expect(1);
+
+ this.data.partner_type.fields.some_char = {type: "char"};
+ this.params.fieldsInfo = {
+ default: {
+ category: {
+ fieldsInfo: {default: {some_char: { context: "{'a': parent.foo}"}}},
+ relatedFields: {some_char: {type: "char"}},
+ viewType: 'default',
+ },
+ foo: {},
+ },
+ };
+
+ var model = createModel({
+ Model: BasicModel,
+ data: this.data,
+ });
+
+ model.load(this.params).then(function (resultID) {
+ var changes = {
+ category: {operation: 'ADD_M2M', ids: [{id: 12}]}
+ };
+ model.notifyChanges(resultID, changes).then(function () {
+ var record = model.get(resultID);
+ var categoryRecord = record.data.category.data[0];
+ assert.deepEqual(categoryRecord.getContext({fieldName: 'some_char'}), {a:'gnap'},
+ "should properly evaluate context");
+ });
+ });
+ model.destroy();
+ });
+
QUnit.test('can fetch a list', function (assert) {
assert.expect(4);