diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 20f8059df6f..97d0644c2b7 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1277,7 +1277,7 @@ export class PosGlobalState extends PosModel { taxes = [...taxes].sort(function (tax1, tax2) { return tax1.sequence - tax2.sequence; }); - _(taxes).each(function (tax) { + taxes.forEach((tax) => { if (tax.amount_type === "group") { all_taxes = _collect_taxes(tax.children_tax_ids, all_taxes); } else { @@ -1328,7 +1328,7 @@ export class PosGlobalState extends PosModel { var cached_tax_amounts = {}; if (handle_price_include) { - _(taxes.reverse()).each(function (tax) { + taxes.reverse().forEach(function (tax) { if (tax.include_base_amount) { base = recompute_base( base, @@ -1378,7 +1378,7 @@ export class PosGlobalState extends PosModel { var taxes_vals = []; i = 0; var cumulated_tax_included_amount = 0; - _(taxes.reverse()).each(function (tax) { + taxes.reverse().forEach(function (tax) { if (tax.price_include || tax.is_base_affected) { var tax_base_amount = base; } else { @@ -2458,7 +2458,7 @@ export class Orderline extends PosModel { qty, this.pos.currency.rounding ); - _(all_taxes.taxes).each(function (tax) { + all_taxes.taxes.forEach(function (tax) { taxtotal += tax.amount; taxdetail[tax.id] = tax.amount; }); @@ -2481,7 +2481,7 @@ export class Orderline extends PosModel { var mapped_included_taxes = []; var new_included_taxes = []; var self = this; - _(taxes).each(function (tax) { + taxes.forEach((tax) => { var line_taxes = self.pos.get_taxes_after_fp([tax.id], order.fiscal_position); if (line_taxes.length && line_taxes[0].price_include) { new_included_taxes = new_included_taxes.concat(line_taxes); diff --git a/addons/portal_rating/static/src/xml/portal_tools.xml b/addons/portal_rating/static/src/xml/portal_tools.xml index c85fb5f2daf..46c39d2e432 100644 --- a/addons/portal_rating/static/src/xml/portal_tools.xml +++ b/addons/portal_rating/static/src/xml/portal_tools.xml @@ -8,13 +8,13 @@ t-att-style="inline_mode ? 'display:inline' : ''" t-attf-aria-label="#{Math.round(val * 100) / 100} stars on 5" t-attf-title="#{Math.round(val * 100) / 100} stars on 5"> - + - + @@ -74,13 +74,13 @@
- + - +
diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 43614060017..32c7e59f1bb 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -76,8 +76,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/session.js', 'web/static/src/legacy/js/core/cookie_utils.js', - 'web/static/lib/underscore/underscore.js', - 'web/static/lib/underscore.string/lib/underscore.string.js', 'web/static/lib/moment/moment.js', 'web/static/lib/luxon/luxon.js', 'web/static/lib/owl/owl.js', @@ -123,7 +121,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/js/libs/download.js', 'web/static/src/legacy/js/libs/jquery.js', 'web/static/src/legacy/js/libs/moment.js', - 'web/static/src/legacy/js/libs/underscore.js', 'web/static/src/legacy/js/libs/pdfjs.js', 'web/static/src/legacy/js/libs/zoomodoo.js', 'web/static/src/legacy/js/libs/jSignatureCustom.js', @@ -307,8 +304,6 @@ This module provides the core of the Odoo Web Client. ('include', 'web.assets_frontend_minimal'), - 'web/static/lib/underscore/underscore.js', - 'web/static/lib/underscore.string/lib/underscore.string.js', 'web/static/lib/moment/moment.js', 'web/static/lib/owl/owl.js', 'web/static/lib/owl/odoo_module.js', @@ -354,7 +349,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/js/libs/download.js', 'web/static/src/legacy/js/libs/jquery.js', 'web/static/src/legacy/js/libs/moment.js', - 'web/static/src/legacy/js/libs/underscore.js', 'web/static/src/legacy/js/libs/pdfjs.js', 'web/static/src/legacy/js/libs/zoomodoo.js', 'web/static/src/legacy/js/libs/jSignatureCustom.js', diff --git a/addons/web/static/lib/py.js/lib/py_extras.js b/addons/web/static/lib/py.js/lib/py_extras.js index 367539c6fe9..0f4ae0134e3 100644 --- a/addons/web/static/lib/py.js/lib/py_extras.js +++ b/addons/web/static/lib/py.js/lib/py_extras.js @@ -326,15 +326,14 @@ datetime.timedelta = py.type('timedelta', null, { ss = s; }); }); - var s = _.str.sprintf("%d:%02d:%02d", hh, mm, ss); + var s = `${hh.toFixed(0)}:${mm.toFixed(0).padStart(2,"0")}:${ss.toFixed(0).padStart(2,"0")}` if (this.days) { - s = _.str.sprintf("%d day%s, %s", - this.days, - (this.days != 1 && this.days != -1) ? 's' : '', - s); + s = `${this.days.toFixed(0)} day${ + this.days != 1 && this.days != -1 ? "s" : "" + }, ${s}`; } if (this.microseconds) { - s = _.str.sprintf("%s.%06d", s, this.microseconds); + s = `${s}.${this.microseconds.toFixed(0).padStart(6, "0")}`; } return py.str.fromJSON(s); }, @@ -545,12 +544,18 @@ datetime.datetime = py.type('datetime', null, { return py.str.fromJSON(args.format.toJSON() .replace(/%([A-Za-z])/g, function (m, c) { switch (c) { - case 'Y': return _.str.sprintf('%04d', self.year); - case 'm': return _.str.sprintf('%02d', self.month); - case 'd': return _.str.sprintf('%02d', self.day); - case 'H': return _.str.sprintf('%02d', self.hour); - case 'M': return _.str.sprintf('%02d', self.minute); - case 'S': return _.str.sprintf('%02d', self.second); + case "Y": + return self.year.toFixed(0).padStart(4, "0"); + case "m": + return self.month.toFixed(0).padStart(2, "0"); + case "d": + return self.day.toFixed(0).padStart(2, "0"); + case "H": + return self.hour.toFixed(0).padStart(2, "0"); + case "M": + return self.minute.toFixed(0).padStart(2, "0"); + case "S": + return self.second.toFixed(0).padStart(2, "0"); } throw new Error('ValueError: No known conversion for ' + m); })); @@ -635,8 +640,8 @@ datetime.date = py.type('date', null, { .replace(/%([A-Za-z])/g, function (m, c) { switch (c) { case 'Y': return self.year; - case 'm': return _.str.sprintf('%02d', self.month); - case 'd': return _.str.sprintf('%02d', self.day); + case 'm': return self.month.toFixed(0).padStart(2, "0"); + case 'd': return self.day.toFixed(0).padStart(2, "0"); } throw new Error('ValueError: No known conversion for ' + m); })); @@ -786,9 +791,13 @@ time.strftime = py.PY_def.fromJSON(function () { return py.PY_call(py.PY_getAttr(d, 'strftime'), [args.format]); }); -var args = _.map(('year month day hour minute second ' - + 'years months weeks days hours minutes seconds ' - + 'weekday leapdays yearday nlyearday').split(' '), function (arg) { +var args = ( + 'year month day hour minute second '+ + 'years months weeks days hours minutes seconds '+ + 'weekday leapdays yearday nlyearday' +) +.split(" ") +.map( (arg) => { switch (arg) { case 'years':case 'months':case 'days':case 'leapdays':case 'weeks': case 'hours':case 'minutes':case 'seconds': diff --git a/addons/web/static/src/legacy/js/core/py_utils.js b/addons/web/static/src/legacy/js/core/py_utils.js index b16e23f7fa5..fc6f081c7c6 100644 --- a/addons/web/static/src/legacy/js/core/py_utils.js +++ b/addons/web/static/src/legacy/js/core/py_utils.js @@ -106,7 +106,7 @@ function wrap_context(context) { function eval_contexts(contexts, evaluation_context) { evaluation_context = Object.assign(pycontext(), evaluation_context || {}); - return _(contexts).reduce(function (result_context, ctx) { + return contexts.reduce((result_context, ctx) => { // __eval_context evaluations can lead to some of `contexts`'s // values being null, skip them as well as empty contexts if (Object.keys(ctx || {}).length === 0) { return result_context; } @@ -143,7 +143,7 @@ function eval_domains(domains, evaluation_context) { domains[0].length === 1 && (domains[0][0] === "|" || domains[0][0] === "!") ); - _(domains).each(function (domain) { + (domains || []).forEach(function (domain) { if (typeof domain === "string") { // wrap raw strings in domain domain = { __ref: 'domain', __debug: domain }; @@ -189,7 +189,7 @@ function get_normalized_domain(domain_array) { function eval_groupbys(contexts, evaluation_context) { evaluation_context = Object.assign(pycontext(), evaluation_context || {}); var result_group = []; - _(contexts).each(function (ctx) { + (contexts || []).forEach(function (ctx) { if (typeof ctx === "string") { // wrap raw strings in context ctx = { __ref: 'context', __debug: ctx }; diff --git a/addons/web/static/src/legacy/js/core/qweb.js b/addons/web/static/src/legacy/js/core/qweb.js index 8aa392abee3..6710a1b9f54 100644 --- a/addons/web/static/src/legacy/js/core/qweb.js +++ b/addons/web/static/src/legacy/js/core/qweb.js @@ -1,5 +1,7 @@ /** @odoo-module alias=web.QWeb **/ +import { uniqueId } from "@web/core/utils/functions"; +import { range } from "@web/core/utils/numbers"; import translation from "web.translation"; var _t = translation._t; @@ -18,7 +20,9 @@ function QWeb(debug, default_dict, enableTranslation) { } var qweb = new QWeb2.Engine(); qweb.default_dict = Object.assign({}, default_dict || {}, { - '_' : _, + // '_' : _, + 'uniqueId': uniqueId, + 'range' : range, 'JSON': JSON, '_t' : translation._t, '__debug__': debug, diff --git a/addons/web/static/src/legacy/js/libs/jquery.js b/addons/web/static/src/legacy/js/libs/jquery.js index 8ff95b0b5a6..1089b44bc3d 100644 --- a/addons/web/static/src/legacy/js/libs/jquery.js +++ b/addons/web/static/src/legacy/js/libs/jquery.js @@ -114,7 +114,7 @@ $.fn.extend({ events = events.split(' '); return this.each(function () { var el = this; - _.each(events, function (evNameNamespaced) { + events.forEach((evNameNamespaced) => { var evName = evNameNamespaced.split('.')[0]; var handler = $._data(el, 'events')[evName].pop(); $._data(el, 'events')[evName].unshift(handler); diff --git a/addons/web/static/src/legacy/js/widgets/model_field_selector.js b/addons/web/static/src/legacy/js/widgets/model_field_selector.js index bfbe3049f16..0b494f32a00 100644 --- a/addons/web/static/src/legacy/js/widgets/model_field_selector.js +++ b/addons/web/static/src/legacy/js/widgets/model_field_selector.js @@ -155,6 +155,9 @@ var ModelFieldSelector = Widget.extend({ this.$value.html(core.qweb.render(this.template + ".value", { chain: this.popover.chain, pages: this.popover.pages, + findByName : (array, name) => { + return (array || []).find((arr) => arr.name === name) + } })); // Toggle the warning message diff --git a/addons/web/static/src/legacy/xml/base.xml b/addons/web/static/src/legacy/xml/base.xml index 1d0f74a4535..5d2467b1eb5 100644 --- a/addons/web/static/src/legacy/xml/base.xml +++ b/addons/web/static/src/legacy/xml/base.xml @@ -478,7 +478,7 @@ - + @@ -504,7 +504,7 @@ - +