diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-06-28 13:20:10 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-06-29 14:58:04 +0200 |
| commit | b954cd64835eb2c251ba0890293079b7bcebd460 (patch) | |
| tree | 370d267b9be3f15813a8b16d0ee63d9aaa993d22 /addons/web/static/tests/views/basic_model_tests.js | |
| parent | 2846887ea80ad164fabb4b1e0742629330a527f5 (diff) | |
[FIX] web: BasicModel: send correct context
... when reading and writing on a record (especially inside lists).
Before this rev., the context sent when reading a record, and when
writing records inside lists (editable list views) wasn't correct.
This caused an issue in Sales > Products (variant activated) >
open a product with variants > click on variant prices > edit the
prices of a variant: the value wasn't saved correctly (because the
inverse function requires 'active_id' to be in the context and it
wasn't the case).
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
| -rw-r--r-- | addons/web/static/tests/views/basic_model_tests.js | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/addons/web/static/tests/views/basic_model_tests.js b/addons/web/static/tests/views/basic_model_tests.js index 715f6099e0a..eb068f4214c 100644 --- a/addons/web/static/tests/views/basic_model_tests.js +++ b/addons/web/static/tests/views/basic_model_tests.js @@ -72,9 +72,15 @@ QUnit.module('Views', { Model: BasicModel, data: this.data, mockRPC: function (route, args) { - assert.strictEqual(args.kwargs.context.active_field, 2, - "should have sent the correct context"); + assert.deepEqual(args.kwargs.context, { + active_field: 2, + bin_size: true, + someKey: 'some value', + }, "should have sent the correct context"); return this._super.apply(this, arguments); + }, + session: { + user_context: {someKey: 'some value'}, } }); @@ -1790,9 +1796,23 @@ QUnit.module('Views', { this.data.partner.records[0].product_ids = [37, 41]; this.params.fieldNames = Object.keys(this.data.partner.fields); + this.params.fieldsInfo = { + form: { + qux: { + context: "{'category': category, 'product_ids': product_ids}", + domain: "[['id', 'in', category], ['id', 'in', product_ids]]", + relatedFields: this.data.partner.fields, + }, + category: { + relatedFields: this.data.partner_type.fields, + }, + product_ids: { + relatedFields: this.data.product.fields, + }, + }, + }; + this.params.viewType = 'form'; this.params.res_id = 1; - this.params.context = "{'category': category, 'product_ids': product_ids}"; - this.params.domain = "[['id', 'in', category], ['id', 'in', product_ids]]"; var model = createModel({ Model: BasicModel, @@ -1801,8 +1821,8 @@ QUnit.module('Views', { model.load(this.params).then(function (resultID) { var record = model.get(resultID); - var context = record.getContext(); - var domain = record.getDomain(); + var context = record.getContext({fieldName: 'qux'}); + var domain = record.getDomain({fieldName: 'qux'}); assert.deepEqual(context, { category: [12], |
