From d186efbec5499fee89f036023449005791e32c0e Mon Sep 17 00:00:00 2001 From: Parthiv Patel Date: Mon, 22 Jan 2024 08:34:32 +0000 Subject: [PATCH] [PATCH] Upstream patch - 22012024 --- .../11.1/end-migrate_update_taxes.py | 12 +++++ addons/l10n_vn/data/l10n_vn_chart_data.xml | 2 +- addons/web/static/lib/Chart/Chart.js | 45 ++++++++++++++----- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py b/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py index 15292ca850..105fdcabe9 100644 --- a/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py +++ b/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py @@ -4,6 +4,18 @@ from flectra.addons.account.models.chart_template import update_taxes_from_templ def migrate(cr, version): + env = api.Environment(cr, SUPERUSER_ID, {}) + # We had corrupted data, handle the correction so the tax update can proceed. + # See https://github.com/flectra/flectra/commit/7b07df873535446f97abc1de9176b9332de5cb07 + taxes_to_check = ('vat_purchase_81_return', 'vat_77_purchase_return') + tax_ids = env['ir.model.data'].search([('name', 'in', taxes_to_check)]).mapped('res_id') + for tax in env['account.tax'].browse(tax_ids): + for child in tax.children_tax_ids: + if child.type_tax_use not in ('none', tax.type_tax_use): + # set the child to it's parent's value + child.type_tax_use = tax.type_tax_use + + # Update taxes new_template_to_tax = update_taxes_from_templates(cr, 'l10n_ch.l10nch_chart_template') if new_template_to_tax: _, new_tax_ids = zip(*new_template_to_tax) diff --git a/addons/l10n_vn/data/l10n_vn_chart_data.xml b/addons/l10n_vn/data/l10n_vn_chart_data.xml index 04bc0c0b2a..3adec59e65 100644 --- a/addons/l10n_vn/data/l10n_vn_chart_data.xml +++ b/addons/l10n_vn/data/l10n_vn_chart_data.xml @@ -12,7 +12,7 @@ 111 113 - + diff --git a/addons/web/static/lib/Chart/Chart.js b/addons/web/static/lib/Chart/Chart.js index 969df7c6be..d4e81575dc 100644 --- a/addons/web/static/lib/Chart/Chart.js +++ b/addons/web/static/lib/Chart/Chart.js @@ -1,7 +1,7 @@ /*! - * Chart.js v2.9.3 + * Chart.js v2.9.4 * https://www.chartjs.org - * (c) 2019 Chart.js Contributors + * (c) 2020 Chart.js Contributors * Released under the MIT License */ (function (global, factory) { @@ -2103,6 +2103,10 @@ if (typeof window !== 'undefined') { var chartjsColor = Color; +function isValidKey(key) { + return ['__proto__', 'prototype', 'constructor'].indexOf(key) === -1; +} + /** * @namespace Chart.helpers */ @@ -2278,7 +2282,7 @@ var helpers = { } if (helpers.isObject(source)) { - var target = {}; + var target = Object.create(source); var keys = Object.keys(source); var klen = keys.length; var k = 0; @@ -2299,6 +2303,12 @@ var helpers = { * @private */ _merger: function(key, target, source, options) { + if (!isValidKey(key)) { + // We want to ensure we do not copy prototypes over + // as this can pollute global namespaces + return; + } + var tval = target[key]; var sval = source[key]; @@ -2314,6 +2324,12 @@ var helpers = { * @private */ _mergerIf: function(key, target, source) { + if (!isValidKey(key)) { + // We want to ensure we do not copy prototypes over + // as this can pollute global namespaces + return; + } + var tval = target[key]; var sval = source[key]; @@ -3812,7 +3828,7 @@ helpers$1.extend(DatasetController.prototype, { */ _configure: function() { var me = this; - me._config = helpers$1.merge({}, [ + me._config = helpers$1.merge(Object.create(null), [ me.chart.options.datasets[me._type], me.getDataset(), ], { @@ -7082,7 +7098,8 @@ function updateDims(chartArea, params, layout) { chartArea.h = newHeight; // return true if chart area changed in layout's direction - return layout.horizontal ? newWidth !== chartArea.w : newHeight !== chartArea.h; + var sizes = layout.horizontal ? [newWidth, chartArea.w] : [newHeight, chartArea.h]; + return sizes[0] !== sizes[1] && (!isNaN(sizes[0]) || !isNaN(sizes[1])); } } @@ -8094,7 +8111,7 @@ var core_scaleService = { }, getScaleDefaults: function(type) { // Return the scale defaults merged with the global settings so that we always use the latest ones - return this.defaults.hasOwnProperty(type) ? helpers$1.merge({}, [core_defaults.scale, this.defaults[type]]) : {}; + return this.defaults.hasOwnProperty(type) ? helpers$1.merge(Object.create(null), [core_defaults.scale, this.defaults[type]]) : {}; }, updateScaleDefaults: function(type, additions) { var me = this; @@ -9169,7 +9186,7 @@ core_defaults._set('global', { * returns a deep copy of the result, thus doesn't alter inputs. */ function mergeScaleConfig(/* config objects ... */) { - return helpers$1.merge({}, [].slice.call(arguments), { + return helpers$1.merge(Object.create(null), [].slice.call(arguments), { merger: function(key, target, source, options) { if (key === 'xAxes' || key === 'yAxes') { var slen = source[key].length; @@ -9209,9 +9226,9 @@ function mergeScaleConfig(/* config objects ... */) { * a deep copy of the result, thus doesn't alter inputs. */ function mergeConfig(/* config objects ... */) { - return helpers$1.merge({}, [].slice.call(arguments), { + return helpers$1.merge(Object.create(null), [].slice.call(arguments), { merger: function(key, target, source, options) { - var tval = target[key] || {}; + var tval = target[key] || Object.create(null); var sval = source[key]; if (key === 'scales') { @@ -9228,7 +9245,7 @@ function mergeConfig(/* config objects ... */) { } function initConfig(config) { - config = config || {}; + config = config || Object.create(null); // Do NOT use mergeConfig for the data object because this method merges arrays // and so would change references to labels and datasets, preventing data updates. @@ -11209,6 +11226,8 @@ function computeLabelSizes(ctx, tickFonts, ticks, caches) { var widths = []; var heights = []; var offsets = []; + var widestLabelSize = 0; + var highestLabelSize = 0; var i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, height, nestedLabel, widest, highest; for (i = 0; i < length; ++i) { @@ -11236,11 +11255,13 @@ function computeLabelSizes(ctx, tickFonts, ticks, caches) { widths.push(width); heights.push(height); offsets.push(lineHeight / 2); + widestLabelSize = Math.max(width, widestLabelSize); + highestLabelSize = Math.max(height, highestLabelSize); } garbageCollect(caches, length); - widest = widths.indexOf(Math.max.apply(null, widths)); - highest = heights.indexOf(Math.max.apply(null, heights)); + widest = widths.indexOf(widestLabelSize); + highest = heights.indexOf(highestLabelSize); function valueAt(idx) { return {