From f5ecd878ff6774b180a59dcc4dd72dc447d7e602 Mon Sep 17 00:00:00 2001 From: Tran Thanh Phuc Date: Wed, 10 Feb 2021 22:48:21 +0700 Subject: [PATCH] [IMP] stock_location_tray: black, isort, prettier --- .../odoo/addons/stock_location_tray | 1 + setup/stock_location_tray/setup.py | 6 ++++ .../static/src/js/stock_location_tray.js | 28 +++++++++---------- 3 files changed, 21 insertions(+), 14 deletions(-) create mode 120000 setup/stock_location_tray/odoo/addons/stock_location_tray create mode 100644 setup/stock_location_tray/setup.py diff --git a/setup/stock_location_tray/odoo/addons/stock_location_tray b/setup/stock_location_tray/odoo/addons/stock_location_tray new file mode 120000 index 000000000..5c2ed7153 --- /dev/null +++ b/setup/stock_location_tray/odoo/addons/stock_location_tray @@ -0,0 +1 @@ +../../../../stock_location_tray \ No newline at end of file diff --git a/setup/stock_location_tray/setup.py b/setup/stock_location_tray/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_location_tray/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_location_tray/static/src/js/stock_location_tray.js b/stock_location_tray/static/src/js/stock_location_tray.js index 9675b8aa5..67f38a8ff 100644 --- a/stock_location_tray/static/src/js/stock_location_tray.js +++ b/stock_location_tray/static/src/js/stock_location_tray.js @@ -1,4 +1,4 @@ -odoo.define("stock_location_tray.tray", function(require) { +odoo.define("stock_location_tray.tray", function (require) { "use strict"; var basicFields = require("web.basic_fields"); @@ -34,7 +34,7 @@ odoo.define("stock_location_tray.tray", function(require) { globalAlpha: 0.8, cellPadding: 2, - init: function(parent, name, record, options) { + init: function (parent, name, record, options) { this._super.apply(this, arguments); this.nodeOptions = _.defaults(this.nodeOptions, {}); if ("clickAction" in (options || {})) { @@ -44,7 +44,7 @@ odoo.define("stock_location_tray.tray", function(require) { } }, - isSet: function() { + isSet: function () { if (Object.keys(this.value).length === 0) { return false; } @@ -54,14 +54,14 @@ odoo.define("stock_location_tray.tray", function(require) { return this._super.apply(this, arguments); }, - start: function() { + start: function () { // Setup resize events to redraw the canvas this._resizeDebounce = this._resizeDebounce.bind(this); this._resizePromise = null; $(window).on("resize", this._resizeDebounce); var self = this; - return this._super.apply(this, arguments).then(function() { + return this._super.apply(this, arguments).then(function () { if (self.clickAction) { self.$el.css("cursor", "pointer"); } @@ -75,7 +75,7 @@ odoo.define("stock_location_tray.tray", function(require) { }); }, - _onClick: function(ev) { + _onClick: function (ev) { if (!this.isSet()) { return; } @@ -115,7 +115,7 @@ odoo.define("stock_location_tray.tray", function(require) { model: this.model, method: this.clickAction, args: [[this.res_id], coordX, coordY], - }).then(function(action) { + }).then(function (action) { self.trigger_up("do_action", {action: action}); }); }, @@ -125,15 +125,15 @@ odoo.define("stock_location_tray.tray", function(require) { * It is useless to render on each resize event. * */ - _resizeDebounce: function() { + _resizeDebounce: function () { clearTimeout(this._resizePromise); var self = this; - this._resizePromise = setTimeout(function() { + this._resizePromise = setTimeout(function () { self._render(); }, 20); }, - destroy: function() { + destroy: function () { $(window).off("resize", this._resizeDebounce); this._super.apply(this, arguments); }, @@ -144,7 +144,7 @@ odoo.define("stock_location_tray.tray", function(require) { * * @returns {Promise} */ - _render: function() { + _render: function () { if (this._ready) { return this._renderInDOM(); } @@ -159,7 +159,7 @@ odoo.define("stock_location_tray.tray", function(require) { * @param {jQueryElement} canvas - the DOM canvas to draw * @returns {Boolean} */ - resizeCanvasToDisplaySize: function(canvas) { + resizeCanvasToDisplaySize: function (canvas) { // Look up the size the canvas is being displayed var width = canvas.clientWidth; var height = canvas.clientHeight; @@ -179,7 +179,7 @@ odoo.define("stock_location_tray.tray", function(require) { * Should be called only if the canvas is already in DOM * */ - _renderInDOM: function() { + _renderInDOM: function () { this.canvas = this.$el[0]; var canvas = this.canvas; var ctx = canvas.getContext("2d"); @@ -202,7 +202,7 @@ odoo.define("stock_location_tray.tray", function(require) { * @param {List} selected - A list containing the position (x,y) of the * selected cell (can be empty if no cell is selected) */ - _drawMatrix: function(canvas, ctx, cells, selected) { + _drawMatrix: function (canvas, ctx, cells, selected) { var colors = { 0: this.cellColorEmpty, 1: this.cellColorNotEmpty,