diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-04-14 11:22:07 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-14 22:36:55 +0200 |
| commit | 0494d612749cd0b7e937d3828775ca54961a29b9 (patch) | |
| tree | 74c7d00b31e2110ce06ed4b2ce7e9683a75dd640 /addons/web/static/tests/views/basic_model_tests.js | |
| parent | 2eda2a7296dd5aeaeae3cea82736d72534a22e1f (diff) | |
[FIX] web: readonly fields may be edited
The readonly attribute of a field in its description can be
overriden in the views (e.g. with modifiers). So readonly fields
may actually be edited from views in which there is a modifiers
on their node overriding the default value.
Before this rev., readonly fields couldn't be saved, even if they
could be edited from views (with such modifiers).
For instance, it wasn't possible to change the value of the
partner_id field in a draft sale_order.
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
| -rw-r--r-- | addons/web/static/tests/views/basic_model_tests.js | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/addons/web/static/tests/views/basic_model_tests.js b/addons/web/static/tests/views/basic_model_tests.js index a81c4a13602..9c9220f8c65 100644 --- a/addons/web/static/tests/views/basic_model_tests.js +++ b/addons/web/static/tests/views/basic_model_tests.js @@ -988,65 +988,6 @@ QUnit.module('Views', { model.destroy(); }); - QUnit.test('dont write on readonly fields (except if create)', function (assert) { - assert.expect(6); - - this.params.fieldNames = ['foo', 'bar']; - this.data.partner.onchanges.foo = function (obj) { - obj.bar = obj.foo.length; - }; - this.data.partner.fields.bar.readonly = true; - - var model = createModel({ - Model: BasicModel, - data: this.data, - mockRPC: function (route, args) { - if (args.method === 'write') { - assert.deepEqual(args.args[1], {foo: "verylongstring"}, - "should only save foo field"); - } - if (args.method === 'create') { - assert.deepEqual(args.args[0], { - foo: "anotherverylongstring", - bar: 21, - }, "should also save bar field in create mode"); - } - return this._super(route, args); - }, - }); - - model.load(this.params).then(function (resultID) { - var record = model.get(resultID); - assert.strictEqual(record.data.bar, 2, - "should be initialized with correct value"); - - model.notifyChanges(resultID, {foo: "verylongstring"}); - - record = model.get(resultID); - assert.strictEqual(record.data.bar, 14, - "should be changed with correct value"); - - model.save(resultID); - }); - - // start again, but with a new record - delete this.params.res_id; - model.load(this.params).then(function (resultID) { - var record = model.get(resultID); - assert.strictEqual(record.data.bar, false, - "should be initialized with correct value"); - - model.notifyChanges(resultID, {foo: "anotherverylongstring"}); - - record = model.get(resultID); - assert.strictEqual(record.data.bar, 21, - "should be changed with correct value"); - - model.save(resultID); - }); - model.destroy(); - }); - QUnit.test('default_get with one2many values', function (assert) { assert.expect(1); |
