diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-07-26 11:27:11 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2017-07-27 11:34:04 +0200 |
| commit | 72ed3a153a1f4c718fee33ac8550298e8a29f6cd (patch) | |
| tree | cdc06e861ab8ad9a0c221f8ea6ba1093e857f295 /addons/pad | |
| parent | 3d6420d4b3f062f12d7c18d7d9a976e2299b3444 (diff) | |
[FIX] web,pad: record is not considered dirty when pad is loaded
The pad widget does something unconventional: it creates the pad url
only when rendering in edit mode. This was done to prevent creating pad
by default for record in readonly mode.
Because of that, if the user clicks on create, then discard, the record was
considered dirty, so a confirmation modal popped up. In this commit, we
just make sure that the initial setValue from the rendering does not
'dirty' the record.
Diffstat (limited to 'addons/pad')
| -rw-r--r-- | addons/pad/static/src/js/pad.js | 2 | ||||
| -rw-r--r-- | addons/pad/static/tests/pad_tests.js | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/addons/pad/static/src/js/pad.js b/addons/pad/static/src/js/pad.js index 9637072274e..b59f3f0bc04 100644 --- a/addons/pad/static/src/js/pad.js +++ b/addons/pad/static/src/js/pad.js @@ -111,7 +111,7 @@ var FieldPad = AbstractField.extend({ // We need to write the url of the pad to trigger // the write function which updates the actual value // of the field to the value of the pad content - self._setValue(result.url); + self._setValue(result.url, {doNotSetDirty: true}); }); } }, diff --git a/addons/pad/static/tests/pad_tests.js b/addons/pad/static/tests/pad_tests.js index 69342f5de6e..2aa8f7fe1db 100644 --- a/addons/pad/static/tests/pad_tests.js +++ b/addons/pad/static/tests/pad_tests.js @@ -148,4 +148,40 @@ QUnit.module('pad widget', { delete FieldPad.prototype.isPadConfigured; }); + QUnit.test('pad widget is not considered dirty at creation', function (assert) { + assert.expect(2); + + var form = createView({ + View: FormView, + model: 'task', + data: this.data, + arch:'<form>' + + '<sheet>' + + '<group>' + + '<field name="description" widget="pad"/>' + + '</group>' + + '</sheet>' + + '</form>', + mockRPC: function (route, args) { + if (!args.method) { + return $.when(true); + } + return this._super.apply(this, arguments); + }, + session: { + userName: "batman", + }, + }); + var def = form.canBeDiscarded(); + + assert.strictEqual($('.modal').length, 0, + "should have no confirmation modal opened"); + + assert.strictEqual(def.state(), 'resolved', + "can be discarded was succesfully resolved"); + form.destroy(); + delete FieldPad.prototype.isPadConfigured; + }); + + }); |
