diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-07-27 10:30:40 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2017-07-27 11:34:05 +0200 |
| commit | ecdcc65a9080fee876ca9cd82ab6385988557205 (patch) | |
| tree | a4ea3c7d7b1e6b96967d44a6f2982994435bf7c2 /addons/pad/static/src | |
| parent | 72ed3a153a1f4c718fee33ac8550298e8a29f6cd (diff) | |
[FIX] pad: force writing url, even if it did not change
Before this commit, the pad widget did not force the view to save the
current value, since it did not change (pad values are just the url for
the pad). However, this is a problem for the server, since it uses the
fact that the web client forces a save to update the description field
in the model (get the data from the pad server and add it to the
database).
This was not a big deal when looking at the pad (the pad widget fetches
its data each time), but it is a problem that the database is not
synchronized with the current data.
Diffstat (limited to 'addons/pad/static/src')
| -rw-r--r-- | addons/pad/static/src/js/pad.js | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/addons/pad/static/src/js/pad.js b/addons/pad/static/src/js/pad.js index b59f3f0bc04..4068ff24ead 100644 --- a/addons/pad/static/src/js/pad.js +++ b/addons/pad/static/src/js/pad.js @@ -39,6 +39,25 @@ var FieldPad = AbstractField.extend({ this.$(".oe_configured").addClass('hidden'); return; } + if (this.mode === 'edit' && _.str.startsWith(this.value, 'http')) { + this.url = this.value; + // please close your eyes and look elsewhere... + // Since the pad value (the url) will not change during the edition + // process, we have a problem: the description field will not be + // properly updated. We need to explicitely write the value each + // time someone edit the record in order to force the server to read + // the updated value of the pad and put it in the description field. + // + // However, the basic model optimizes away the changes if they are + // not really different from the current value. So, we need to + // either add special configuration options to the basic model, or + // to trick him into accepting the same value as being different... + // Guess what we decided... + var url = {}; + url.toJSON = _.constant(this.url); + this._setValue(url); + } + return this._super.apply(this, arguments); }, @@ -75,11 +94,11 @@ var FieldPad = AbstractField.extend({ * @private */ _renderEdit: function () { - if (_.str.startsWith(this.value, 'http')) { + if (this.url) { // here, we have a valid url, so we can simply display an iframe // with the correct src attribute var userName = encodeURIComponent(this.getSession().userName); - var url = this.value + '?showChat=false&userName=' + userName; + var url = this.url + '?showChat=false&userName=' + userName; var content = '<iframe width="100%" height="100%" frameborder="0" src="' + url + '"></iframe>'; this.$('.oe_pad_content').html(content); } else if (this.value) { @@ -111,6 +130,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.url = result.url; self._setValue(result.url, {doNotSetDirty: true}); }); } |
