diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-05-26 13:16:01 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2017-05-26 15:02:29 +0200 |
| commit | 9009c5375ee0dec0fdf5c6257065066ef5a3f6f7 (patch) | |
| tree | 4c303d96151374526282e91df2607915a5c568ec /addons/web/static/tests/views/basic_model_tests.js | |
| parent | 0c28dbf969233990eab01c52abd3f214cc299071 (diff) | |
[FIX] web: fix various issues with eval contexts
Eval contexts are not easy... They should be different when sent to the
server and when evaluated in the web client. In this commit, we fix
some small issues:
- when evaluated on the web client, x2manys should be a list of ids,
when sent to the server, it should be a list of commands
- dates should be converted to string
- always add current_date in the evaluation context, as a magic key (it
was previously only available in row decoration context evaluations)
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
| -rw-r--r-- | addons/web/static/tests/views/basic_model_tests.js | 34 |
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 75d1bc3853a..cc3834e188e 100644 --- a/addons/web/static/tests/views/basic_model_tests.js +++ b/addons/web/static/tests/views/basic_model_tests.js @@ -1444,4 +1444,38 @@ QUnit.module('Views', { model.destroy(); }); + + QUnit.test('has a proper evaluation context', function (assert) { + assert.expect(1); + + this.params.fieldNames = Object.keys(this.data.partner.fields); + this.params.res_id = 1; + + var model = createModel({ + Model: BasicModel, + data: this.data, + }); + + model.load(this.params).then(function (resultID) { + var record = model.get(resultID); + assert.deepEqual(record.evalContext, { + active_id: 1, + active_ids: [1], + active_model: "partner", + bar: 1, + category: [12], + current_date: moment().format('YYYY-MM-DD'), + date: "2017-01-25", + display_name: "first partner", + foo: "blip", + id: 1, + product_id: 37, + product_ids: [], + qux: false, + total: 0 + }, "should use the proper eval context"); + }); + model.destroy(); + }); + });}); |
