From 66f7d393d3d6b0ac77cfde9172be86f77d9b63b1 Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Wed, 11 Oct 2017 10:40:46 +0200 Subject: [FIX] web: debug mode tooltip Display properly the content of context object instead of [object Object]. --- addons/web/static/src/js/views/form/form_renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js index ab491adc9b1..e5a0646dd5c 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -812,7 +812,7 @@ var FormRenderer = BasicRenderer.extend({ _.each(this.allFieldWidgets[this.state.id], function (widget) { var idForLabel = self.idsForLabels[widget.name]; var $label = idForLabel ? self.$('label[for=' + idForLabel + ']') : $(); - if (core.debug || widget.attrs.help || widget.field.help) { + if (config.debug || widget.attrs.help || widget.field.help) { self._addFieldTooltip(widget, $label); } if (widget.attrs.widget === 'upgrade_boolean') { -- cgit v1.2.3 From b8dac2ff32d2e875e2f43c91f702e17adc938f7e Mon Sep 17 00:00:00 2001 From: rgarnau Date: Thu, 12 Oct 2017 09:07:27 +0200 Subject: [FIX] web: integer not properly parsed The parsing of the integers does not escape the thousands separator. issue: Integers are currently not properly parsed. For example, create a database in Spanish language, install product_expiry and in settings activate Lots & Serial Numbers. Go to Products and create a new product. Choose to track by lots and specify the use_time, life_time, etc. When saving, all integers are set to 0 --- addons/web/static/src/js/fields/field_utils.js | 41 ++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js index db5cd34d8b9..14d8848205f 100644 --- a/addons/web/static/src/js/fields/field_utils.js +++ b/addons/web/static/src/js/fields/field_utils.js @@ -421,13 +421,36 @@ function parseDateTime(value, field, options) { throw new Error(_.str.sprintf(core._t("'%s' is not a correct datetime"), value)); } -function parseFloat(value) { +/** + * Parse a String containing number in language formating + * + * @param {string} value + * The string to be parsed with the setting of thousands and + * decimal separator + * @returns {float|NaN} the number value contained in the string representation + */ +function parseNumber(value) { if (core._t.database.parameters.thousands_sep) { var escapedSep = _.str.escapeRegExp(core._t.database.parameters.thousands_sep); value = value.replace(new RegExp(escapedSep, 'g'), ''); } - value = value.replace(core._t.database.parameters.decimal_point, '.'); - var parsed = Number(value); + if (core._t.database.parameters.decimal_point) { + value = value.replace(core._t.database.parameters.decimal_point, '.'); + } + return Number(value); +} + +/** + * Parse a String containing float in language formating + * + * @param {string} value + * The string to be parsed with the setting of thousands and + * decimal separator + * @returns {float} + * @throws {Error} if no float is found respecting the language configuration + */ +function parseFloat(value) { + var parsed = parseNumber(value); if (isNaN(parsed)) { throw new Error(_.str.sprintf(core._t("'%s' is not a correct float"), value)); } @@ -494,9 +517,17 @@ function parseFloatTime(value) { return factor * (hours + (minutes / 60)); } +/** + * Parse a String containing integer with language formating + * + * @param {string} value + * The string to be parsed with the setting of thousands and + * decimal separator + * @returns {integer} + * @throws {Error} if no integer is found respecting the language configuration + */ function parseInteger(value) { - value = value.replace(new RegExp(core._t.database.parameters.thousands_sep, "g"), ''); - var parsed = Number(value); + var parsed = parseNumber(value); // do not accept not numbers or float values if (isNaN(parsed) || parsed % 1 || parsed < -2147483648 || parsed > 2147483647) { throw new Error(_.str.sprintf(core._t("'%s' is not a correct integer"), value)); -- cgit v1.2.3 From 03ef19e40c0fc378c18fa0dbfa830f29be852406 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 11 Oct 2017 16:37:38 +0200 Subject: [FIX] web, hr_timesheet_sheet: make m2o friendly-usable outside of views Before this commit, m2o external button was always floating outside the m2o main DOM element, on the right. This induced problems when using the m2o outside of views (like in Odoo Studio). Now, the m2o design is made so that this button is inside the m2o, except in form views where we expect the button to overflow in the tables' right paddings. --- addons/web/static/src/js/fields/relational_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 194165b2206..9218897fb1f 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -422,7 +422,7 @@ var FieldMany2One = AbstractField.extend({ _updateExternalButton: function () { var has_external_button = !this.nodeOptions.no_open && !this.floating && this.isSet(); this.$external_button.toggle(has_external_button); - this.$el.toggleClass('o_with_button', has_external_button); + this.$el.toggleClass('o_with_button', has_external_button); // Should not be required anymore but kept for compatibility }, -- cgit v1.2.3 From 7d448d57e34511eb668a695e9238a2096c05411e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 11 Oct 2017 08:55:03 +0200 Subject: [FIX] web: fix issue with default_get/onchange and one2many Before this commit, there was a bug when creating a new record which contains a one2many with an onchange. The commands sent to the onchange did not contain the full information. Here is how you could reproduce the issue: install expense, go to the expense list view, select the 2 lines, then, in the 'action' menu in the control panel, choose 'Expense: submit to manager'. In the new expense sheet, you could see that there were two lines in the one2many expense_line_ids. However, these lines are empty. The reason is that the commands sent in the onchange were 2 commands 0, with {} as data. So, in short, the BasicModel did generate the proper commands, but with empty data, in the specific case when we have a non empty one2many in a default_get, then an onchange. To solve this issue, I had to fix 2 things: the internal data struture was wrongly updated, and the commands should be generated with all the data, and not only the changes. --- .../web/static/src/js/views/basic/basic_model.js | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 377ae7157d3..073d8599f06 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2433,7 +2433,12 @@ var BasicModel = AbstractModel.extend({ _generateChanges: function (record, options) { options = options || {}; var viewType = options.viewType || record.viewType; - var changes = _.extend({}, record._changes); + var changes; + if ('changesOnly' in options && !options.changesOnly) { + changes = _.extend({}, record.data, record._changes); + } else { + changes = _.extend({}, record._changes); + }; var withReadonly = options.withReadonly || false; var commands = this._generateX2ManyCommands(record, { changesOnly: 'changesOnly' in options ? options.changesOnly : true, @@ -2479,10 +2484,14 @@ var BasicModel = AbstractModel.extend({ * current value of the parent record. * * @param {Object} record + * @param {Object} [options] This option object will be given to the private + * method _generateX2ManyCommands. In particular, it is useful to be able + * to send changesOnly:true to get all data, not only the current changes. * @returns {Object} the data */ - _generateOnChangeData: function (record) { - var commands = this._generateX2ManyCommands(record, {withReadonly: true}); + _generateOnChangeData: function (record, options) { + options = _.extend({}, options || {}, {withReadonly: true}); + var commands = this._generateX2ManyCommands(record, options); var data = _.extend(this.get(record.id, {raw: true}).data, commands); // 'display_name' is automatically added to the list of fields to fetch, // when fetching a record, even if it doesn't appear in the view. However, @@ -2601,6 +2610,7 @@ var BasicModel = AbstractModel.extend({ relRecord = _.findWhere(relRecordUpdated, {res_id: list.res_ids[i]}); changes = relRecord ? this._generateChanges(relRecord, options) : {}; if (!_.isEmpty(changes)) { + delete changes.id; command = x2ManyCommands.update(relRecord.res_id, changes); didChange = true; } else { @@ -3170,16 +3180,7 @@ var BasicModel = AbstractModel.extend({ if (value[0] === 6) { // REPLACE_WITH _.each(value[2], function (res_id) { - r = self._makeDataPoint({ - modelName: x2manyList.model, - context: x2manyList.context, - fieldsInfo: fieldsInfo, - fields: fields, - parentID: x2manyList.id, - res_id: res_id, - viewType: viewType, - }); - x2manyList._changes.push({operation: 'ADD', id: r.id}); + x2manyList._changes.push({operation: 'ADD', resID: res_id}); }); var def = self._readUngroupedList(x2manyList).then(function () { return $.when( @@ -3291,7 +3292,7 @@ var BasicModel = AbstractModel.extend({ options.fieldName = fields; } var context = this._getContext(record, options); - var currentData = this._generateOnChangeData(record); + var currentData = this._generateOnChangeData(record, {changesOnly: false}); return self._rpc({ model: record.model, -- cgit v1.2.3 From 66b692a5eb2350a8c22e9be0b05f08b8b7f6ae9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 12 Oct 2017 10:27:27 +0200 Subject: [FIX] web: fix display issue with fieldSelection When displaying a many2one values, in edit mode, the option did not properly display some characters. --- addons/web/static/src/js/fields/relational_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 9218897fb1f..cbcab4743f6 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -1863,7 +1863,7 @@ var FieldSelection = AbstractField.extend({ for (var i = 0 ; i < this.values.length ; i++) { this.$el.append($('