diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-08-10 11:49:15 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-08-10 13:56:22 +0200 |
| commit | 87133a8235aa71db49566e9a1179ab66b68e87ec (patch) | |
| tree | 6e06c1062e95f9a95d27be4b5aae2c6e7c0ec8b4 /addons/web/static/tests/views/basic_model_tests.js | |
| parent | 9b4c8a4e318cdabbd21ebb28c61b17ad02874daa (diff) | |
[FIX] web: BasicModel: correctly reload new records
Commit 7cd2f6370 (in 10.0) recently added attribute special='cancel'
on the 'Cancel' buttons of the Settings views in Odoo. The attribute
wasn't really supported in this case by the old web framework, so
this commit also slightly adapted it, and made it reload the whole
webclient when such a button is clicked.
This commit now needs to be forwardported in saas-16, so we have to
handle the case in the new views as well. Before this rev., it
crashed, because the BasicModel tried to reload a new record (the
one of the Settings form view), so basically it performed a 'read'
RPC on a virtual ID like 'virtual_123', and the server didn't really
appreciate.
This rev. handles the case where a new record is reloaded, and
simply performs a 'default_get' instead of a read. Bonus point:
with the new views, we don't have to reload the whole webclient.
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
| -rw-r--r-- | addons/web/static/tests/views/basic_model_tests.js | 35 |
1 files changed, 35 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 63214b0f2d7..8c23fc4f97c 100644 --- a/addons/web/static/tests/views/basic_model_tests.js +++ b/addons/web/static/tests/views/basic_model_tests.js @@ -1973,4 +1973,39 @@ QUnit.module('Views', { model.destroy(); }); + QUnit.test('reload a new record', function (assert) { + assert.expect(6); + + this.params.context = {}; + this.params.fieldNames = ['product_id', 'category', 'product_ids']; + this.params.res_id = undefined; + this.params.type = 'record'; + + var model = createModel({ + Model: BasicModel, + data: this.data, + mockRPC: function (route, args) { + assert.step(args.method); + return this._super(route, args); + }, + }); + + model.load(this.params).then(function (recordID) { + model.reload(recordID).then(function (recordID) { + assert.verifySteps(['default_get', 'default_get'], + "two default_get RPCs should have been done"); + var record = model.get(recordID); + assert.strictEqual(record.data.product_id, false, + "m2o default value should be false"); + assert.deepEqual(record.data.product_ids.data, [], + "o2m default should be []"); + assert.deepEqual(record.data.category.data, [], + "m2m default should be []"); + }); + }); + + model.destroy(); + }); + + });}); |
