forked from Techsystech/web
[FIX] isort, prettier, black: JS lint in all affect modules
parent
872ae6cb09
commit
9bd63dd24a
|
@ -1,11 +1,13 @@
|
|||
odoo.define('support_branding.crash_manager_tests', function (require) {
|
||||
odoo.define("support_branding.crash_manager_tests", function (require) {
|
||||
"use strict";
|
||||
|
||||
const CrashManager = require('web.CrashManager').CrashManager;
|
||||
const testUtils = require('web.test_utils');
|
||||
/* global QUnit*/
|
||||
|
||||
const CrashManager = require("web.CrashManager").CrashManager;
|
||||
const testUtils = require("web.test_utils");
|
||||
const createActionManager = testUtils.createActionManager;
|
||||
|
||||
QUnit.module('support_branding', {}, function() {
|
||||
QUnit.module("support_branding", {}, function () {
|
||||
QUnit.test("Error Dialog is created", async function (assert) {
|
||||
// No of assertion expected.
|
||||
assert.expect(5);
|
||||
|
@ -14,53 +16,63 @@ odoo.define('support_branding.crash_manager_tests', function (require) {
|
|||
var actionManager = await createActionManager({
|
||||
services: {
|
||||
crash_manager: CrashManager,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Check if action with crash manager service was created.
|
||||
assert.notOk(_.isEmpty(actionManager), "Action manager with " +
|
||||
"crash manager service should be created and not empty");
|
||||
assert.notOk(
|
||||
_.isEmpty(actionManager),
|
||||
"Action manager with " +
|
||||
"crash manager service should be created and not empty"
|
||||
);
|
||||
|
||||
// Test custom error
|
||||
let error = {
|
||||
type: 'Support Branding Odoo Client Error',
|
||||
message: 'Message',
|
||||
const error = {
|
||||
type: "Support Branding Odoo Client Error",
|
||||
message: "Message",
|
||||
data: {
|
||||
debug: 'Traceback',
|
||||
debug: "Traceback",
|
||||
},
|
||||
};
|
||||
// NB: This will use the saved res.config settings of support
|
||||
// branding containing the support mail. It is fetched in crash
|
||||
// manager init function as saved in res.config settings.
|
||||
// attached is a default data xml with sample data.
|
||||
actionManager.call('crash_manager', 'show_error', error);
|
||||
actionManager.call("crash_manager", "show_error", error);
|
||||
await testUtils.nextTick();
|
||||
var $mail_dialog = 'form.support-branding-submit-form';
|
||||
var $mail_dialog = "form.support-branding-submit-form";
|
||||
|
||||
// Confirm if we have a form and its required elements.
|
||||
assert.containsOnce($, $mail_dialog, "Error dialog should be " +
|
||||
"opened and showing mail section on footer");
|
||||
assert.containsOnce($, '.support-desc', 'We should have a ' +
|
||||
'textarea to add our issues');
|
||||
assert.containsOnce($, 'button.support-btn', 'We should have a ' +
|
||||
'send mail button to send support mail');
|
||||
assert.containsOnce(
|
||||
$,
|
||||
$mail_dialog,
|
||||
"Error dialog should be opened and showing mail section on footer"
|
||||
);
|
||||
assert.containsOnce(
|
||||
$,
|
||||
".support-desc",
|
||||
"We should have a textarea to add our issues"
|
||||
);
|
||||
assert.containsOnce(
|
||||
$,
|
||||
"button.support-btn",
|
||||
"We should have a send mail button to send support mail"
|
||||
);
|
||||
|
||||
// Add a test text mail.
|
||||
$(".support-desc").val("Send this as a test mail to " +
|
||||
"configured support mail");
|
||||
$(".support-desc").val(
|
||||
"Send this as a test mail to configured support mail"
|
||||
);
|
||||
|
||||
// Try to send mail, by default a popup will be triggered
|
||||
// defaulting to form call of 'mailto'.
|
||||
await testUtils.dom.click($('button.support-btn'),
|
||||
{allowInvisible: true});
|
||||
await testUtils.dom.click($("button.support-btn"), {allowInvisible: true});
|
||||
|
||||
// Close error dialog
|
||||
await testUtils.dom.click($('button.close'),
|
||||
{allowInvisible: true});
|
||||
await testUtils.dom.click($("button.close"), {allowInvisible: true});
|
||||
|
||||
// Confirm dialog was closed
|
||||
assert.containsNone($, $mail_dialog,
|
||||
"Error Dialog should be closed");
|
||||
assert.containsNone($, $mail_dialog, "Error Dialog should be closed");
|
||||
|
||||
actionManager.destroy();
|
||||
});
|
||||
|
|
|
@ -8,7 +8,6 @@ odoo.define("web_advanced_search.RelationalOwl", function (require) {
|
|||
const FieldMany2One = relationalFields.FieldMany2One;
|
||||
const FieldManagerMixin = require("web.FieldManagerMixin");
|
||||
const {useListener} = require("web.custom_hooks");
|
||||
/* global owl */
|
||||
const {Component} = owl;
|
||||
const {xml} = owl.tags;
|
||||
|
||||
|
|
|
@ -15,6 +15,10 @@ odoo.define("web_calendar_color_field.CalendarModel", function (require) {
|
|||
*
|
||||
* If the field is also added to filters, and a color field is defined,
|
||||
* we use that color field as colorIndex.
|
||||
*
|
||||
* @param {Object} element: ''
|
||||
* @param {Array} events: ''
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_loadColors: function (element, events) {
|
||||
var self = this;
|
||||
|
|
|
@ -11,7 +11,7 @@ odoo.define("web_calendar_slot_duration.CalendarModel", function (require) {
|
|||
* @override
|
||||
*/
|
||||
_getFullCalendarOptions: function () {
|
||||
var result = this._super.call(this, arguments);
|
||||
var result = this._super.apply(this, arguments);
|
||||
result.slotDuration =
|
||||
this.data.context.calendar_slot_duration ||
|
||||
result.slotDuration ||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global Uint8Array, base64js */
|
||||
/* global base64js */
|
||||
// Copyright 2018 Therp BV <https://therp.nl>
|
||||
// Copyright 2021 Tecnativa - Alexandre D. Díaz
|
||||
// License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
@ -24,7 +24,8 @@ odoo.define("web_drop_target", function (require) {
|
|||
*/
|
||||
start: function () {
|
||||
const $body = $("body");
|
||||
this._dropZoneNS = _.uniqueId("o_dz_"); // For event namespace used when multiple chat window is open
|
||||
// For event namespace used when multiple chat window is open
|
||||
this._dropZoneNS = _.uniqueId("o_dz_");
|
||||
$body.on(
|
||||
"dragleave." + this._dropZoneNS,
|
||||
this._onBodyFileDragLeave.bind(this)
|
||||
|
@ -159,7 +160,7 @@ odoo.define("web_drop_target", function (require) {
|
|||
if (
|
||||
_.isEmpty(this._get_drop_items(ev)) &&
|
||||
this._checkDragOver() &&
|
||||
(controller == undefined || controller.jsID === this.controllerID)
|
||||
(controller === undefined || controller.jsID === this.controllerID)
|
||||
) {
|
||||
const drop_zone_offset = this.$drop_zone.offset();
|
||||
const overlay_css = {
|
||||
|
@ -212,6 +213,7 @@ odoo.define("web_drop_target", function (require) {
|
|||
*
|
||||
* @private
|
||||
* @param {MouseEvent} ev
|
||||
* @returns {Object} drop items
|
||||
*/
|
||||
_get_drop_items: function (ev) {
|
||||
let drop_items = [];
|
||||
|
@ -250,6 +252,7 @@ odoo.define("web_drop_target", function (require) {
|
|||
* @param {String} res_model
|
||||
* @param {Number} res_id
|
||||
* @param {Object} extra_data
|
||||
* @returns {Void}
|
||||
*/
|
||||
_create_attachment: function (file, reader, res_model, res_id, extra_data) {
|
||||
// Helper to upload an attachment and update the sidebar
|
||||
|
|
|
@ -134,7 +134,7 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
|
|||
if (blacklisted_ids.length > 0) {
|
||||
domain.push(["id", "not in", blacklisted_ids]);
|
||||
}
|
||||
|
||||
/* eslint-disable complexity */
|
||||
self._rpc({
|
||||
model: self.field.relation,
|
||||
method: "name_search",
|
||||
|
@ -201,16 +201,15 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
|
|||
// 3- if not set locally, check if it's set globally via ir.config_parameter
|
||||
// 4- if set globally, apply its value
|
||||
// 5- if not set globally either, check if returned values are more than node's limit
|
||||
var search_more = values.length > self.limit;
|
||||
if (!_.isUndefined(self.nodeOptions.search_more)) {
|
||||
var search_more = is_option_set(self.nodeOptions.search_more);
|
||||
search_more = is_option_set(self.nodeOptions.search_more);
|
||||
} else if (
|
||||
!_.isUndefined(ir_options["web_m2x_options.search_more"])
|
||||
) {
|
||||
var search_more = is_option_set(
|
||||
search_more = is_option_set(
|
||||
ir_options["web_m2x_options.search_more"]
|
||||
);
|
||||
} else {
|
||||
var search_more = values.length > self.limit;
|
||||
}
|
||||
|
||||
if (search_more) {
|
||||
|
@ -349,6 +348,7 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
|
|||
resolve(values);
|
||||
}
|
||||
});
|
||||
/* eslint-enable complexity */
|
||||
});
|
||||
this.orderer.add(def);
|
||||
|
||||
|
@ -483,7 +483,7 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
|
|||
this._super(attrs);
|
||||
var limit = ir_options["web_m2x_options.field_limit_entries"];
|
||||
if (!_.isUndefined(limit)) {
|
||||
attrs.limit = parseInt(limit);
|
||||
attrs.limit = parseInt(limit, 10);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -21,7 +21,8 @@ odoo.define("web_pwa_oca.PWAManager", function (require) {
|
|||
"Service workers are not supported! Maybe you are not using HTTPS or you work in private mode."
|
||||
)
|
||||
);
|
||||
} else {
|
||||
}
|
||||
if ("serviceWorker" in navigator) {
|
||||
this._service_worker = navigator.serviceWorker;
|
||||
this.registerServiceWorker("/service-worker.js");
|
||||
}
|
||||
|
|
|
@ -61,13 +61,15 @@
|
|||
"click .o_kanban_mobile_tab": "_onMobileTabClicked",
|
||||
"click .o_kanban_mobile_add_column": "_onMobileQuickCreateClicked",
|
||||
}),
|
||||
ANIMATE: true, // Allows to disable animations for the tests
|
||||
// Allows to disable animations for the tests
|
||||
ANIMATE: true,
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this.activeColumnIndex = 0; // Index of the currently displayed column
|
||||
// Index of the currently displayed column
|
||||
this.activeColumnIndex = 0;
|
||||
this._scrollPosition = null;
|
||||
},
|
||||
/**
|
||||
|
@ -377,7 +379,8 @@
|
|||
db_id: column.db_id,
|
||||
onSuccess: () => self._layoutUpdate(animate),
|
||||
});
|
||||
} else {
|
||||
}
|
||||
if (column.data.isOpen) {
|
||||
this._layoutUpdate(animate);
|
||||
}
|
||||
return Promise.resolve();
|
||||
|
@ -396,16 +399,19 @@
|
|||
_renderGrouped: function (fragment) {
|
||||
var self = this;
|
||||
var newFragment = document.createDocumentFragment();
|
||||
this._super.apply(this, [newFragment]);
|
||||
var fragment_change = [newFragment];
|
||||
this._super.apply(this, fragment_change);
|
||||
this.defs.push(
|
||||
Promise.all(this.defs).then(function () {
|
||||
var data = [];
|
||||
_.each(self.state.data, function (group) {
|
||||
if (!group.value) {
|
||||
group = _.extend({}, group, {value: _t("Undefined")});
|
||||
data.unshift(group);
|
||||
} else {
|
||||
data.push(group);
|
||||
var grp = group;
|
||||
if (!grp.value) {
|
||||
grp = _.extend({}, grp, {value: _t("Undefined")});
|
||||
data.unshift(grp);
|
||||
}
|
||||
if (grp.value) {
|
||||
data.push(grp);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -445,7 +451,7 @@
|
|||
* Retrieve the Jquery node (.o_kanban_group) for a list of a given widgets
|
||||
*
|
||||
* @private
|
||||
* @param widgets
|
||||
* @param {Object} widgets: ''
|
||||
* @returns {jQuery} the matching .o_kanban_group widgets
|
||||
*/
|
||||
_toNode: function (widgets) {
|
||||
|
@ -462,8 +468,8 @@
|
|||
* Update the given column to the updated positions
|
||||
*
|
||||
* @private
|
||||
* @param $column The jquery column
|
||||
* @param cssProperties Use to update column
|
||||
* @param {Object} $column The jquery column
|
||||
* @param {Object} cssProperties Use to update column
|
||||
* @param {Boolean} [animate=false] set to true to animate
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
@ -493,6 +499,7 @@
|
|||
|
||||
/**
|
||||
* @private
|
||||
* @param {MouseEvent} event
|
||||
*/
|
||||
_onMobileQuickCreateClicked: function (event) {
|
||||
if (event) {
|
||||
|
|
|
@ -21,7 +21,6 @@ odoo.define("web_responsive", function (require) {
|
|||
const PatchableAttachmentViewer = patchMixin(AttachmentViewer);
|
||||
const ControlPanel = require("web.ControlPanel");
|
||||
const SearchPanel = require("web/static/src/js/views/search_panel.js");
|
||||
/* global owl */
|
||||
const {QWeb, Context} = owl;
|
||||
const {useState, useContext} = owl.hooks;
|
||||
|
||||
|
|
|
@ -20,32 +20,32 @@ odoo.define(
|
|||
isShiftKey,
|
||||
}) {
|
||||
const queryElem = this.state.query.find(
|
||||
(queryElem) =>
|
||||
queryElem.filterId === filterId &&
|
||||
queryElem.value === value &&
|
||||
queryElem.operator === operator
|
||||
(queryElem_val) =>
|
||||
queryElem_val.filterId === filterId &&
|
||||
queryElem_val.value === value &&
|
||||
queryElem_val.operator === operator
|
||||
);
|
||||
if (!queryElem) {
|
||||
const {groupId} = this.state.filters[filterId];
|
||||
this.state.query.push({
|
||||
filterId,
|
||||
groupId,
|
||||
label,
|
||||
value,
|
||||
operator,
|
||||
});
|
||||
if (isShiftKey) {
|
||||
const groupId = Math.random();
|
||||
const group_id = Math.random();
|
||||
this.state.query.push({
|
||||
filterId,
|
||||
groupId,
|
||||
label,
|
||||
value,
|
||||
operator,
|
||||
});
|
||||
} else {
|
||||
const {groupId} = this.state.filters[filterId];
|
||||
this.state.query.push({
|
||||
filterId,
|
||||
groupId,
|
||||
group_id,
|
||||
label,
|
||||
value,
|
||||
operator,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (queryElem) {
|
||||
queryElem.label = label;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -36,6 +36,8 @@ odoo.define("web_search_with_and/static/src/js/search_bar.js", function (require
|
|||
this._closeAutoComplete();
|
||||
},
|
||||
|
||||
/* eslint-disable complexity */
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {KeyboardEvent} ev
|
||||
|
@ -100,7 +102,7 @@ odoo.define("web_search_with_and/static/src/js/search_bar.js", function (require
|
|||
}
|
||||
}
|
||||
break;
|
||||
case "ArrowUp":
|
||||
case "ArrowUp": {
|
||||
ev.preventDefault();
|
||||
let previousIndex = this.state.focusedItem - 1;
|
||||
if (previousIndex < 0) {
|
||||
|
@ -108,6 +110,7 @@ odoo.define("web_search_with_and/static/src/js/search_bar.js", function (require
|
|||
}
|
||||
this.state.focusedItem = previousIndex;
|
||||
break;
|
||||
}
|
||||
case "Backspace":
|
||||
if (!this.state.inputValue.length) {
|
||||
const facets = this.model.get("facets");
|
||||
|
@ -124,7 +127,8 @@ odoo.define("web_search_with_and/static/src/js/search_bar.js", function (require
|
|||
/* Falls through */
|
||||
case "Tab":
|
||||
if (this.state.inputValue.length) {
|
||||
ev.preventDefault(); // Keep the focus inside the search bar
|
||||
// Keep the focus inside the search bar
|
||||
ev.preventDefault();
|
||||
this._selectSource(currentItem);
|
||||
}
|
||||
break;
|
||||
|
@ -135,5 +139,6 @@ odoo.define("web_search_with_and/static/src/js/search_bar.js", function (require
|
|||
break;
|
||||
}
|
||||
},
|
||||
/* eslint-enable complexity */
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Show a big banner in the top of the page if the context has been
|
||||
// Changed in another tab or window (in the same browser)
|
||||
|
||||
var con = [];
|
||||
var lastCtx = null;
|
||||
window.con = [];
|
||||
window.lastCtx = null;
|
||||
|
||||
addEventListener(
|
||||
"connect",
|
||||
|
@ -10,21 +10,21 @@ addEventListener(
|
|||
"use strict";
|
||||
|
||||
var port = ee.ports[0];
|
||||
con.push(port);
|
||||
window.con.push(port);
|
||||
|
||||
port.onmessage = function (e) {
|
||||
var newCtx = e.data;
|
||||
|
||||
if (lastCtx && newCtx !== lastCtx) {
|
||||
con.forEach(function (eport) {
|
||||
if (window.lastCtx && newCtx !== window.lastCtx) {
|
||||
window.con.forEach(function (eport) {
|
||||
eport.postMessage({
|
||||
type: "newCtx",
|
||||
newCtx: newCtx,
|
||||
lastCtx: lastCtx,
|
||||
lastCtx: window.lastCtx,
|
||||
});
|
||||
});
|
||||
}
|
||||
lastCtx = newCtx;
|
||||
window.lastCtx = newCtx;
|
||||
};
|
||||
},
|
||||
false
|
||||
|
|
|
@ -159,21 +159,23 @@ odoo.define("web_widget_numeric_step.field", function (require) {
|
|||
* @param {String} mode can be "plus" or "minus"
|
||||
*/
|
||||
_doStep: function (mode) {
|
||||
let mode_val = mode;
|
||||
let cval = 0;
|
||||
try {
|
||||
const field = this.record.fields[this.name];
|
||||
cval = field_utils.parse[field.type](this.$input.val());
|
||||
} catch (e) {
|
||||
cval = this.value;
|
||||
mode = false; // Only set the value in this case
|
||||
// Only set the value in this case
|
||||
mode_val = false;
|
||||
}
|
||||
if (mode === "plus") {
|
||||
if (mode_val === "plus") {
|
||||
cval += this._config.step;
|
||||
} else if (mode === "minus") {
|
||||
} else if (mode_val === "minus") {
|
||||
cval -= this._config.step;
|
||||
}
|
||||
const nval = this._sanitizeNumberValue(cval);
|
||||
if (nval !== this.lastSetValue || !mode) {
|
||||
if (nval !== this.lastSetValue || !mode_val) {
|
||||
this.$input.val(nval);
|
||||
// Every time that user update the value we must trigger an
|
||||
// onchange method.
|
||||
|
|
|
@ -176,6 +176,9 @@ odoo.define("web_widget_x2many_2d_matrix.widget", function (require) {
|
|||
|
||||
/**
|
||||
* Determine if a field represented by field_def can be aggregated
|
||||
*
|
||||
* @param {Object} field_def: field def
|
||||
* @returns {Boolean} if field def is aggregatable
|
||||
*/
|
||||
is_aggregatable: function (field_def) {
|
||||
return field_def.type in {float: 1, monetary: 1, integer: 1};
|
||||
|
|
Loading…
Reference in New Issue