mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_location_tray: black, isort, prettier
This commit is contained in:
committed by
Hai Lang
parent
abad67be50
commit
f5ecd878ff
1
setup/stock_location_tray/odoo/addons/stock_location_tray
Symbolic link
1
setup/stock_location_tray/odoo/addons/stock_location_tray
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../../stock_location_tray
|
||||||
6
setup/stock_location_tray/setup.py
Normal file
6
setup/stock_location_tray/setup.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
odoo.define("stock_location_tray.tray", function(require) {
|
odoo.define("stock_location_tray.tray", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var basicFields = require("web.basic_fields");
|
var basicFields = require("web.basic_fields");
|
||||||
@@ -34,7 +34,7 @@ odoo.define("stock_location_tray.tray", function(require) {
|
|||||||
globalAlpha: 0.8,
|
globalAlpha: 0.8,
|
||||||
cellPadding: 2,
|
cellPadding: 2,
|
||||||
|
|
||||||
init: function(parent, name, record, options) {
|
init: function (parent, name, record, options) {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.nodeOptions = _.defaults(this.nodeOptions, {});
|
this.nodeOptions = _.defaults(this.nodeOptions, {});
|
||||||
if ("clickAction" in (options || {})) {
|
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) {
|
if (Object.keys(this.value).length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -54,14 +54,14 @@ odoo.define("stock_location_tray.tray", function(require) {
|
|||||||
return this._super.apply(this, arguments);
|
return this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function() {
|
start: function () {
|
||||||
// Setup resize events to redraw the canvas
|
// Setup resize events to redraw the canvas
|
||||||
this._resizeDebounce = this._resizeDebounce.bind(this);
|
this._resizeDebounce = this._resizeDebounce.bind(this);
|
||||||
this._resizePromise = null;
|
this._resizePromise = null;
|
||||||
$(window).on("resize", this._resizeDebounce);
|
$(window).on("resize", this._resizeDebounce);
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
return this._super.apply(this, arguments).then(function() {
|
return this._super.apply(this, arguments).then(function () {
|
||||||
if (self.clickAction) {
|
if (self.clickAction) {
|
||||||
self.$el.css("cursor", "pointer");
|
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()) {
|
if (!this.isSet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ odoo.define("stock_location_tray.tray", function(require) {
|
|||||||
model: this.model,
|
model: this.model,
|
||||||
method: this.clickAction,
|
method: this.clickAction,
|
||||||
args: [[this.res_id], coordX, coordY],
|
args: [[this.res_id], coordX, coordY],
|
||||||
}).then(function(action) {
|
}).then(function (action) {
|
||||||
self.trigger_up("do_action", {action: 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.
|
* It is useless to render on each resize event.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
_resizeDebounce: function() {
|
_resizeDebounce: function () {
|
||||||
clearTimeout(this._resizePromise);
|
clearTimeout(this._resizePromise);
|
||||||
var self = this;
|
var self = this;
|
||||||
this._resizePromise = setTimeout(function() {
|
this._resizePromise = setTimeout(function () {
|
||||||
self._render();
|
self._render();
|
||||||
}, 20);
|
}, 20);
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function () {
|
||||||
$(window).off("resize", this._resizeDebounce);
|
$(window).off("resize", this._resizeDebounce);
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
@@ -144,7 +144,7 @@ odoo.define("stock_location_tray.tray", function(require) {
|
|||||||
*
|
*
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
_render: function() {
|
_render: function () {
|
||||||
if (this._ready) {
|
if (this._ready) {
|
||||||
return this._renderInDOM();
|
return this._renderInDOM();
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ odoo.define("stock_location_tray.tray", function(require) {
|
|||||||
* @param {jQueryElement} canvas - the DOM canvas to draw
|
* @param {jQueryElement} canvas - the DOM canvas to draw
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
resizeCanvasToDisplaySize: function(canvas) {
|
resizeCanvasToDisplaySize: function (canvas) {
|
||||||
// Look up the size the canvas is being displayed
|
// Look up the size the canvas is being displayed
|
||||||
var width = canvas.clientWidth;
|
var width = canvas.clientWidth;
|
||||||
var height = canvas.clientHeight;
|
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
|
* Should be called only if the canvas is already in DOM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
_renderInDOM: function() {
|
_renderInDOM: function () {
|
||||||
this.canvas = this.$el[0];
|
this.canvas = this.$el[0];
|
||||||
var canvas = this.canvas;
|
var canvas = this.canvas;
|
||||||
var ctx = canvas.getContext("2d");
|
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
|
* @param {List} selected - A list containing the position (x,y) of the
|
||||||
* selected cell (can be empty if no cell is selected)
|
* selected cell (can be empty if no cell is selected)
|
||||||
*/
|
*/
|
||||||
_drawMatrix: function(canvas, ctx, cells, selected) {
|
_drawMatrix: function (canvas, ctx, cells, selected) {
|
||||||
var colors = {
|
var colors = {
|
||||||
0: this.cellColorEmpty,
|
0: this.cellColorEmpty,
|
||||||
1: this.cellColorNotEmpty,
|
1: this.cellColorNotEmpty,
|
||||||
|
|||||||
Reference in New Issue
Block a user