From ea6e7379a35e91f9ad064e5ad1e87c5177ea067b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 9 Feb 2018 15:47:43 +0100 Subject: [DOC] doc: update/add documentation on js framework The state of the JS documentation was quite sad, not updated in a long time. With this commit, we rework a lot of the JS doc. Most notably, we add a section 'Javascript Cheatsheet' (help on some common customization tasks) and rewrite the 'Javascript Reference' totally. Note that the JS reference page also contains a reference on all field widgets. This work is just the beginning, it is probably not complete, but at least we will have a foundation. --- addons/web/static/src/js/fields/basic_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/fields') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 8a42f91161c..eb0a4a2cdaf 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1757,7 +1757,7 @@ var StatInfo = AbstractField.extend({ var FieldPercentPie = AbstractField.extend({ template: 'FieldPercentPie', - supportedFieldTypes: ['integer'], + supportedFieldTypes: ['integer', 'float'], /** * Register some useful references for later use throughout the widget. -- cgit v1.2.3 From 9a9da5763b38a3bce54e9c4870af0032e38cacc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Wed, 4 Apr 2018 10:09:33 +0200 Subject: [FIX] web: no record abandon on discard from default_get/onchange Before this commit, when some records were created from an `onchange`, we have the following weird behaviour: Suppose that this record has some required fields that are empty. When we click on this record, then somewhere else, the record disappears from the list. This is because the records contains invalid fields, and it is wrongfully assuming that the record to be discarded comes from "Add an item". A previous commit [1] fixed a bit this issue with `default_get`, but since it relied on a fragile heuristic, we decide to apply the correct fix with this commit. [1] https://github.com/odoo/odoo/commit/b09f0c99be2b13d33986414485556d87da186d65 --- addons/web/static/src/js/fields/relational_fields.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/fields') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index aa71fca9c25..c4984b69441 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -1029,7 +1029,7 @@ var FieldX2Many = AbstractField.extend({ */ _onEditLine: function (ev) { ev.stopPropagation(); - this.trigger_up('freeze_order', {id: this.value.id}); + this.trigger_up('edited_list', { id: this.value.id }); var editedRecord = this.value.data[ev.data.index]; this.renderer.setRowMode(editedRecord.id, 'edit') .done(ev.data.onSuccess); @@ -1117,7 +1117,7 @@ var FieldX2Many = AbstractField.extend({ _onResequence: function (event) { event.stopPropagation(); var self = this; - this.trigger_up('freeze_order', {id: this.value.id}); + this.trigger_up('edited_list', { id: this.value.id }); var rowIDs = event.data.rowIDs.slice(); var rowID = rowIDs.pop(); var defs = _.map(rowIDs, function (rowID, index) { @@ -1261,7 +1261,7 @@ var FieldOne2Many = FieldX2Many.extend({ } } else if (!this.creatingRecord) { this.creatingRecord = true; - this.trigger_up('freeze_order', {id: this.value.id}); + this.trigger_up('edited_list', { id: this.value.id }); this._setValue({ operation: 'CREATE', position: this.editable, -- cgit v1.2.3 From 9c1c2c55c23655c56dcd04c3d80da59b5bcab177 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 12 Apr 2018 09:02:59 +0200 Subject: [FIX] web: one2many: add new record with 'Save & New' Consider the following scenario involving a one2many list (non editable) inside a form view: - click on 'Add an item', a model opens, - fill the fields and click on 'Save & Close', - reopen the freshly created record, - maybe make some changes (this is optional, but makes sense), - click on 'Save & New', - fill the fields and click on 'Save & Close', -> the second created record isn't added to the list. The problem comes from the fact that when the dialog is opened for the second time (in this case by clicking on a record), the 'save' handler registers an 'UPDATE' command. While this is correct for the 'Save & New' click (as we update an existing record), this isn't for the second record which doesn't exist yet, and thus requires an 'ADD' command. This rev. ensures that the two cases are handled in the 'save' handler given to the dialog. OPW 1829723 --- .../web/static/src/js/fields/relational_fields.js | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src/js/fields') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index c4984b69441..bc44d6b659a 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -1291,12 +1291,27 @@ var FieldOne2Many = FieldX2Many.extend({ // we don't want interference with the components upstream. ev.stopPropagation(); + var self = this; var id = ev.data.id; - // trigger an empty 'UPDATE' operation when the user clicks on 'Save' in - // the dialog, to notify the main record that a subrecord of this - // relational field has changed (those changes will be already stored on - // that subrecord, thanks to the 'Save'). - var onSaved = this._setValue.bind(this, { operation: 'UPDATE', id: id }, {}); + var onSaved = function (record, hasChanged) { + if (!hasChanged) { + return; + } + if (_.some(self.value.data, {id: record.id})) { + // the record already exists in the relation, so trigger an + // empty 'UPDATE' operation when the user clicks on 'Save' in + // the dialog, to notify the main record that a subrecord of + // this relational field has changed (those changes will be + // already stored on that subrecord, thanks to the 'Save'). + self._setValue({ operation: 'UPDATE', id: record.id }); + } else { + // the record isn't in the relation yet, so add it ; this can + // happen if the user clicks on 'Save & New' in the dialog (the + // opened record will be updated, and other records will be + // created) + self._setValue({ operation: 'ADD', id: record.id }); + } + }; this._openFormDialog({ id: id, on_saved: onSaved, -- cgit v1.2.3 From b8b0f947bf7f7abf930a1797fa55c7f7dd33faa2 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Fri, 13 Apr 2018 14:30:46 +0200 Subject: [FIX] web: remove ­ when saving phone number When Odoo display a phone number number, on phone or if VOIP is installed a invisible `­` character was added from 9.0 up to saas-11.2 so an applications such as skype would not be concerned with the number. But if someone copy-pasted from this to somewhere else in Odoo, we would get incorrect number with this invisible caracter. So this change make a special case for the "FieldPhone" so the character is removed from data saved. opw-1834858 closes #24223 --- addons/web/static/src/js/fields/basic_fields.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'addons/web/static/src/js/fields') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index eb0a4a2cdaf..aff339cb4a2 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1013,6 +1013,21 @@ var FieldPhone = FieldEmail.extend({ this.$el.removeClass('o_text_overflow'); }, + /** + * Remove possibly present ­ characters when saving number + * + * @override + * @private + */ + _setValue: function (value, options) { + // NOT NEEDED AS OF SAAS-11.3 + if (value) { + // remove possibly pasted ­ characters + value = value.replace(/\u00AD/g, ''); + } + return this._super(value, options); + }, + /** * Phone fields are clickable in readonly on small screens ~= on phones. * This can be overriden by call-capable modules to display a clickable -- cgit v1.2.3