run pre-commit -a with new prettiers

This commit is contained in:
Guewen Baconnier
2020-03-17 10:56:50 +01:00
committed by Hai Lang
parent d1100c489d
commit 41c0581390
10 changed files with 647 additions and 302 deletions

View File

@@ -1,21 +1,22 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1"> <odoo noupdate="1">
<record id="stock_location_tray_demo" model="stock.location"> <record id="stock_location_tray_demo" model="stock.location">
<field name="name">Tray</field> <field name="name">Tray</field>
<field name="barcode">TRAY</field> <field name="barcode">TRAY</field>
<field name="location_id" ref="stock.stock_location_stock"/> <field name="location_id" ref="stock.stock_location_stock" />
<field name="tray_type_id" ref="stock_location_tray_type_small_8x"/> <field name="tray_type_id" ref="stock_location_tray_type_small_8x" />
<field name="usage">internal</field> <field name="usage">internal</field>
</record> </record>
<!-- When the trays are created, they will create their 'cell' locations. <!-- When the trays are created, they will create their 'cell' locations.
This method will add xmlids on them to be able to reference them in This method will add xmlids on them to be able to reference them in
other demo data and tests. other demo data and tests.
--> -->
<function model="stock.location" name="_create_tray_xmlids"> <function model="stock.location" name="_create_tray_xmlids">
<function eval="[[('cell_in_tray_type_id', '!=', False)]]" model="stock.location" name="search" /> <function
eval="[[('cell_in_tray_type_id', '!=', False)]]"
model="stock.location"
name="search"
/>
<value>stock_location_tray</value> <value>stock_location_tray</value>
</function> </function>
</odoo> </odoo>

View File

@@ -1,74 +1,63 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1"> <odoo noupdate="1">
<record model="stock.location.tray.type" id="stock_location_tray_type_small_32x">
<record model="stock.location.tray.type" id="stock_location_tray_type_small_32x"> <field name="name">Small 32x</field>
<field name="name">Small 32x</field> <field name="code">B10804</field>
<field name="code">B10804</field> <field name="rows">4</field>
<field name="rows">4</field> <field name="cols">8</field>
<field name="cols">8</field> </record>
</record> <record model="stock.location.tray.type" id="stock_location_tray_type_small_16x">
<field name="name">Small 16x</field>
<record model="stock.location.tray.type" id="stock_location_tray_type_small_16x"> <field name="code">B20802</field>
<field name="name">Small 16x</field> <field name="rows">2</field>
<field name="code">B20802</field> <field name="cols">8</field>
<field name="rows">2</field> </record>
<field name="cols">8</field> <record model="stock.location.tray.type" id="stock_location_tray_type_small_8x">
</record> <field name="name">Small 8x</field>
<field name="code">B20402</field>
<record model="stock.location.tray.type" id="stock_location_tray_type_small_8x"> <field name="rows">2</field>
<field name="name">Small 8x</field> <field name="cols">4</field>
<field name="code">B20402</field> </record>
<field name="rows">2</field> <record model="stock.location.tray.type" id="stock_location_tray_type_small_16x_2">
<field name="cols">4</field> <field name="name">Small 16x</field>
</record> <field name="code">B40802</field>
<field name="rows">2</field>
<record model="stock.location.tray.type" id="stock_location_tray_type_small_16x_2"> <field name="cols">8</field>
<field name="name">Small 16x</field> </record>
<field name="code">B40802</field> <record model="stock.location.tray.type" id="stock_location_tray_type_small_16x_3">
<field name="rows">2</field> <field name="name">Small 16x</field>
<field name="cols">8</field> <field name="code">B30404</field>
</record> <field name="rows">4</field>
<field name="cols">4</field>
<record model="stock.location.tray.type" id="stock_location_tray_type_small_16x_3"> </record>
<field name="name">Small 16x</field> <record model="stock.location.tray.type" id="stock_location_tray_type_large_32x">
<field name="code">B30404</field> <field name="name">Large 32x</field>
<field name="rows">4</field> <field name="code">B20804</field>
<field name="cols">4</field> <field name="rows">4</field>
</record> <field name="cols">8</field>
</record>
<record model="stock.location.tray.type" id="stock_location_tray_type_large_32x"> <record model="stock.location.tray.type" id="stock_location_tray_type_large_16x">
<field name="name">Large 32x</field> <field name="name">Large 16x</field>
<field name="code">B20804</field> <field name="code">B30802</field>
<field name="rows">4</field> <field name="rows">2</field>
<field name="cols">8</field> <field name="cols">8</field>
</record> </record>
<record model="stock.location.tray.type" id="stock_location_tray_type_large_8x">
<record model="stock.location.tray.type" id="stock_location_tray_type_large_16x"> <field name="name">Large 8x</field>
<field name="name">Large 16x</field> <field name="code">B30402</field>
<field name="code">B30802</field> <field name="rows">2</field>
<field name="rows">2</field> <field name="cols">4</field>
<field name="cols">8</field> </record>
</record> <record model="stock.location.tray.type" id="stock_location_tray_type_large_4x">
<field name="name">Large 4x</field>
<record model="stock.location.tray.type" id="stock_location_tray_type_large_8x"> <field name="code">B30401</field>
<field name="name">Large 8x</field> <field name="rows">1</field>
<field name="code">B30402</field> <field name="cols">4</field>
<field name="rows">2</field> </record>
<field name="cols">4</field> <record model="stock.location.tray.type" id="stock_location_tray_type_large_16x_2">
</record> <field name="name">Large 16x</field>
<field name="code">B30404</field>
<record model="stock.location.tray.type" id="stock_location_tray_type_large_4x"> <field name="rows">4</field>
<field name="name">Large 4x</field> <field name="cols">4</field>
<field name="code">B30401</field> </record>
<field name="rows">1</field>
<field name="cols">4</field>
</record>
<record model="stock.location.tray.type" id="stock_location_tray_type_large_16x_2">
<field name="name">Large 16x</field>
<field name="code">B30404</field>
<field name="rows">4</field>
<field name="cols">4</field>
</record>
</odoo> </odoo>

View File

@@ -0,0 +1,319 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_location_tray
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__active
msgid "Active"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.actions.act_window,help:stock_location_tray.action_stock_location_tray_type
msgid "Add a Location Tray Type"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_location_tray_type_form
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_location_tray_type_search
msgid "Archived"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location__cell_in_tray_type_id
msgid "Cell Tray Type"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location__tray_matrix
msgid "Cells"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,help:stock_location_tray.field_stock_location__cell_name_format
msgid ""
"Cells sub-locations generated in a tray will be named after this format. "
"Replacement fields between curly braces are used to inject positions. {x}, "
"{y}, and {z} will be replaced by their corresponding position. Complex "
"formatting (such as padding, ...) can be done using the format specification"
" at https://docs.python.org/3/library/string.html#formatstrings"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_move_line_tray
msgid "Close"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__code
msgid "Code"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__cols
msgid "Cols"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__create_uid
msgid "Created by"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__create_date
msgid "Created on"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.actions.act_window,help:stock_location_tray.action_stock_location_tray_type
msgid ""
"Define the number of rows and cols on a tray, depending of the boxes\n"
"size."
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__depth
msgid "Depth"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__depth_per_cell
msgid "Depth Per Cell"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,help:stock_location_tray.field_stock_location_tray_type__depth
msgid "Depth of the tray in mm"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_move_line__tray_dest_matrix
msgid "Destination Cell"
msgstr ""
#. module: stock_location_tray
#: code:addons/stock_location_tray/models/stock_move_line.py:0
#, python-format
msgid "Destination Tray"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__display_name
msgid "Display Name"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_location_tray_type_form
msgid "Disposition"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__height
msgid "Height"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,help:stock_location_tray.field_stock_location_tray_type__height
msgid "Height of the tray in mm"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__id
msgid "ID"
msgstr ""
#. module: stock_location_tray
#: model:ir.model,name:stock_location_tray.model_stock_location
msgid "Inventory Locations"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type____last_update
msgid "Last Modified on"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__write_uid
msgid "Last Updated by"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__write_date
msgid "Last Updated on"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__location_ids
msgid "Location"
msgstr ""
#. module: stock_location_tray
#: code:addons/stock_location_tray/models/stock_location.py:0
#, python-format
msgid "Location %s has sub-locations, it cannot be converted to a tray."
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_location_tray_type_form
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_location_tray_type_search
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_location_tray_type_tree
msgid "Location Tray Type"
msgstr ""
#. module: stock_location_tray
#: model:ir.actions.act_window,name:stock_location_tray.action_stock_location_tray_type
#: model:ir.ui.menu,name:stock_location_tray.menu_stock_location_tray_type
msgid "Location Tray Types"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_location_tray_type_form
msgid "Locations"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__name
msgid "Name"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location__cell_name_format
msgid "Name Format for Cells"
msgstr ""
#. module: stock_location_tray
#: model:ir.model,name:stock_location_tray.model_stock_move_line
msgid "Product Moves (Stock Move Line)"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__rows
msgid "Rows"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_move_line_operation_tree
msgid "Show Destination Tray"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_move_line_operation_tree
msgid "Show Source Tray"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_location_tray_type_form
msgid "Sizes"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_move_line__tray_source_matrix
msgid "Source Cell"
msgstr ""
#. module: stock_location_tray
#: code:addons/stock_location_tray/models/stock_move_line.py:0
#, python-format
msgid "Source Tray"
msgstr ""
#. module: stock_location_tray
#: model:ir.model,name:stock_location_tray.model_stock_location_tray_type
msgid "Stock Location Tray Type"
msgstr ""
#. module: stock_location_tray
#: code:addons/stock_location_tray/models/stock_location_tray_type.py:0
#, python-format
msgid ""
"The tray type {} is used by the following locations and cannot be archived:\n"
"\n"
"{}"
msgstr ""
#. module: stock_location_tray
#: code:addons/stock_location_tray/models/stock_location_tray_type.py:0
#, python-format
msgid ""
"The tray type {} is used by the following locations, it's size cannot be changed:\n"
"\n"
"{}"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_location_form
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_move_line_tray
msgid "Tray"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location__tray_cell_contains_stock
msgid "Tray Cell Contains Stock"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_location_tray_type_form
msgid "Tray Configuration"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__tray_matrix
msgid "Tray Matrix"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location__tray_type_id
msgid "Tray Type"
msgstr ""
#. module: stock_location_tray
#: code:addons/stock_location_tray/models/stock_location.py:0
#, python-format
msgid "Tray locations cannot be archived when they contain products."
msgstr ""
#. module: stock_location_tray
#: code:addons/stock_location_tray/models/stock_location.py:0
#, python-format
msgid "Trays cannot be modified when they contain products."
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,help:stock_location_tray.field_stock_location__tray_cell_contains_stock
msgid "Used to know if a cell of a Tray location is empty."
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__width
msgid "Width"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,field_description:stock_location_tray.field_stock_location_tray_type__width_per_cell
msgid "Width Per Cell"
msgstr ""
#. module: stock_location_tray
#: model:ir.model.fields,help:stock_location_tray.field_stock_location_tray_type__width
msgid "Width of the tray in mm"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_location_tray_type_form
msgid "mm /"
msgstr ""
#. module: stock_location_tray
#: model_terms:ir.ui.view,arch_db:stock_location_tray.view_stock_location_tray_type_form
msgid "mm per cell"
msgstr ""

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>Location Trays</title> <title>Location Trays</title>
<style type="text/css"> <style type="text/css">

View File

@@ -1,50 +1,50 @@
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");
var field_registry = require('web.field_registry'); var field_registry = require("web.field_registry");
var DebouncedField = basicFields.DebouncedField; var DebouncedField = basicFields.DebouncedField;
/** /**
* Shows a canvas with the Tray's cells * Shows a canvas with the Tray's cells
* *
* An action can be configured which is called when a cell is clicked. * An action can be configured which is called when a cell is clicked.
* The action must be an action.multi, it will receive the x and y positions * The action must be an action.multi, it will receive the x and y positions
* of the cell clicked (starting from 0). The action must be configured in * of the cell clicked (starting from 0). The action must be configured in
* the options of the field and be on the same model: * the options of the field and be on the same model:
* *
* <field name="tray_matrix" * <field name="tray_matrix"
* widget="location_tray_matrix" * widget="location_tray_matrix"
* options="{'click_action': 'action_tray_matrix_click'}" * options="{'click_action': 'action_tray_matrix_click'}"
* /> * />
* *
*/ */
var LocationTrayMatrixField = DebouncedField.extend({ var LocationTrayMatrixField = DebouncedField.extend({
className: 'o_field_location_tray_matrix', className: "o_field_location_tray_matrix",
tagName: 'canvas', tagName: "canvas",
supportedFieldTypes: ['serialized'], supportedFieldTypes: ["serialized"],
events: { events: {
'click': '_onClick', click: "_onClick",
}, },
cellColorEmpty: '#ffffff', cellColorEmpty: "#ffffff",
cellColorNotEmpty: '#4e6bfd', cellColorNotEmpty: "#4e6bfd",
selectedColor: '#08f46b', selectedColor: "#08f46b",
selectedLineWidth: 5, selectedLineWidth: 5,
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 || {})) {
this.clickAction = options.clickAction; this.clickAction = options.clickAction;
} else { } else {
this.clickAction = this.nodeOptions.click_action; this.clickAction = this.nodeOptions.click_action;
} }
}, },
isSet: function () { isSet: function() {
if (Object.keys(this.value).length === 0) { if (Object.keys(this.value).length === 0) {
return false; return false;
} }
@@ -54,16 +54,16 @@ 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");
} }
// _super calls _render(), but the function // _super calls _render(), but the function
// resizeCanvasToDisplaySize would resize the canvas // resizeCanvasToDisplaySize would resize the canvas
@@ -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;
} }
@@ -94,8 +94,8 @@ odoo.define('stock_location_tray.tray', function (require) {
rows = cells.length; rows = cells.length;
// We remove 1 to start counting from 0 // We remove 1 to start counting from 0
var coordX = Math.ceil(clickX * cols / width) - 1, var coordX = Math.ceil((clickX * cols) / width) - 1,
coordY = Math.ceil(clickY * rows / height) - 1; coordY = Math.ceil((clickY * rows) / height) - 1;
// If we click on the last pixel on the bottom or the right // If we click on the last pixel on the bottom or the right
// we would get an offset index // we would get an offset index
if (coordX >= cols) { if (coordX >= cols) {
@@ -115,37 +115,36 @@ 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}); });
});
}, },
/** /**
* Debounce the rendering on resize. * Debounce the rendering on resize.
* 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);
}, },
/** /**
* Render the widget only when it is in the DOM. * Render the widget only when it is in the DOM.
* We need the width and height of the widget to draw the canvas. * We need the width and height of the widget to draw the canvas.
* *
* @returns {Promise} * @returns {Promise}
*/ */
_render: function () { _render: function() {
if (this._ready) { if (this._ready) {
return this._renderInDOM(); return this._renderInDOM();
} }
@@ -153,14 +152,14 @@ odoo.define('stock_location_tray.tray', function (require) {
}, },
/** /**
* Resize the canvas width and height to the actual size. * Resize the canvas width and height to the actual size.
* If we don't do that, it will automatically scale to the * If we don't do that, it will automatically scale to the
* CSS size with blurry squares. * CSS size with blurry squares.
* *
* @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;
@@ -176,14 +175,14 @@ odoo.define('stock_location_tray.tray', function (require) {
}, },
/** /**
* Resize the canvas, clear it and redraw the cells * Resize the canvas, clear it and redraw the cells
* 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");
this.resizeCanvasToDisplaySize(ctx.canvas); this.resizeCanvasToDisplaySize(ctx.canvas);
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.save(); ctx.save();
@@ -195,15 +194,15 @@ odoo.define('stock_location_tray.tray', function (require) {
}, },
/** /**
* Draw the cells in the canvas. * Draw the cells in the canvas.
* *
* @param {jQueryElement} canvas - the DOM canvas to draw * @param {jQueryElement} canvas - the DOM canvas to draw
* @param {Object} ctx - the canvas 2d context * @param {Object} ctx - the canvas 2d context
* @param {List} cells - A 2-dimensional list of cells * @param {List} cells - A 2-dimensional list of cells
* @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,
@@ -244,8 +243,10 @@ odoo.define('stock_location_tray.tray', function (require) {
fillHeight += padding; fillHeight += padding;
} }
ctx.fillRect( ctx.fillRect(
x * (w + padding), y * (h + padding), x * (w + padding),
fillWidth, fillHeight, y * (h + padding),
fillWidth,
fillHeight
); );
if (selected && selectedX === x && selectedY === y) { if (selected && selectedX === x && selectedY === y) {
ctx.globalAlpha = 1.0; ctx.globalAlpha = 1.0;
@@ -260,11 +261,9 @@ odoo.define('stock_location_tray.tray', function (require) {
}, },
}); });
field_registry.add("location_tray_matrix", LocationTrayMatrixField);
field_registry.add('location_tray_matrix', LocationTrayMatrixField);
return { return {
LocationTrayMatrixField: LocationTrayMatrixField, LocationTrayMatrixField: LocationTrayMatrixField,
}; };
}); });

View File

@@ -1,11 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<odoo> <odoo>
<template
<template id="stock_location_tray_assets" name="stock.location.tray.assets" inherit_id="web.assets_backend"> id="stock_location_tray_assets"
name="stock.location.tray.assets"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside"> <xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss" href="/stock_location_tray/static/src/scss/stock_location_tray.scss"/> <link
<script type="text/javascript" src="/stock_location_tray/static/src/js/stock_location_tray.js"></script> rel="stylesheet"
type="text/scss"
href="/stock_location_tray/static/src/scss/stock_location_tray.scss"
/>
<script
type="text/javascript"
src="/stock_location_tray/static/src/js/stock_location_tray.js"
/>
</xpath> </xpath>
</template> </template>
</odoo> </odoo>

View File

@@ -1,96 +1,109 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<odoo> <odoo>
<record id="view_stock_location_tray_type_form" model="ir.ui.view">
<record id="view_stock_location_tray_type_form" model="ir.ui.view"> <field name="name">stock.location.tray.type.form</field>
<field name="name">stock.location.tray.type.form</field> <field name="model">stock.location.tray.type</field>
<field name="model">stock.location.tray.type</field> <field name="arch" type="xml">
<field name="arch" type="xml"> <form string="Location Tray Type">
<form string="Location Tray Type"> <div class="oe_button_box" name="button_box">
<div class="oe_button_box" name="button_box"> <button
<button string="Locations" string="Locations"
class="oe_stat_button" class="oe_stat_button"
icon="fa-filter" name="open_locations" icon="fa-filter"
type="object" name="open_locations"
/> type="object"
</div> />
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/> </div>
<label for="name" class="oe_edit_only"/> <widget
<h1><field name="name"/></h1> name="web_ribbon"
<group> title="Archived"
<group string="Tray Configuration" name="settings"> bg_color="bg-danger"
<field name="active" invisible="1"/> attrs="{'invisible': [('active', '=', True)]}"
<field name="code"/> />
<field name="rows"/> <label for="name" class="oe_edit_only" />
<field name="cols"/> <h1>
</group> <field name="name" />
<group string="Sizes" name="size"> </h1>
<label for="width"/> <group>
<div> <group string="Tray Configuration" name="settings">
<field name="width"/> mm / <field name="active" invisible="1" />
<field name="width_per_cell"/> mm per cell <field name="code" />
<field name="rows" />
<field name="cols" />
</group>
<group string="Sizes" name="size">
<label for="width" />
<div>
<field name="width" /> mm /
<field name="width_per_cell" /> mm per cell
</div> </div>
<label for="depth"/> <label for="depth" />
<div> <div>
<field name="depth"/> mm / <field name="depth" /> mm /
<field name="depth_per_cell"/> mm per cell <field name="depth_per_cell" /> mm per cell
</div> </div>
<field name="height"/> <field name="height" />
</group> </group>
<group string="Disposition" name="disposition"> <group string="Disposition" name="disposition">
<field name="tray_matrix" <field
widget="location_tray_matrix" name="tray_matrix"
nolabel="1"/> widget="location_tray_matrix"
</group> nolabel="1"
</group> />
</form> </group>
</field> </group>
</record> </form>
</field>
<record id="view_stock_location_tray_type_search" model="ir.ui.view"> </record>
<field name="name">stock.location.tray.type.search</field> <record id="view_stock_location_tray_type_search" model="ir.ui.view">
<field name="model">stock.location.tray.type</field> <field name="name">stock.location.tray.type.search</field>
<field name="arch" type="xml"> <field name="model">stock.location.tray.type</field>
<search string="Location Tray Type"> <field name="arch" type="xml">
<field name="name"/> <search string="Location Tray Type">
<field name="code"/> <field name="name" />
<separator/> <field name="code" />
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/> <separator />
</search> <filter
</field> string="Archived"
</record> name="inactive"
domain="[('active','=',False)]"
<record id="view_stock_location_tray_type_tree" model="ir.ui.view"> />
<field name="name">stock.location.tray.type</field> </search>
<field name="model">stock.location.tray.type</field> </field>
<field name="arch" type="xml"> </record>
<tree string="Location Tray Type"> <record id="view_stock_location_tray_type_tree" model="ir.ui.view">
<field name="name"/> <field name="name">stock.location.tray.type</field>
<field name="code"/> <field name="model">stock.location.tray.type</field>
<field name="rows"/> <field name="arch" type="xml">
<field name="cols"/> <tree string="Location Tray Type">
</tree> <field name="name" />
</field> <field name="code" />
</record> <field name="rows" />
<field name="cols" />
<record id="action_stock_location_tray_type" model="ir.actions.act_window"> </tree>
<field name="name">Location Tray Types</field> </field>
<field name="res_model">stock.location.tray.type</field> </record>
<field name="type">ir.actions.act_window</field> <record id="action_stock_location_tray_type" model="ir.actions.act_window">
<field name="view_id" ref="view_stock_location_tray_type_tree"/> <field name="name">Location Tray Types</field>
<field name="search_view_id" ref="view_stock_location_tray_type_search"/> <field name="res_model">stock.location.tray.type</field>
<field name="context"></field> <field name="type">ir.actions.act_window</field>
<field name="help" type="html"> <field name="view_id" ref="view_stock_location_tray_type_tree" />
<p class="o_view_nocontent_smiling_face"> <field name="search_view_id" ref="view_stock_location_tray_type_search" />
<field name="context" />
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Add a Location Tray Type Add a Location Tray Type
</p><p> </p>
<p>
Define the number of rows and cols on a tray, depending of the boxes Define the number of rows and cols on a tray, depending of the boxes
size. size.
</p> </p>
</field> </field>
</record> </record>
<menuitem
<menuitem action="action_stock_location_tray_type" action="action_stock_location_tray_type"
id="menu_stock_location_tray_type" id="menu_stock_location_tray_type"
parent="stock.menu_warehouse_config" sequence="10"/> parent="stock.menu_warehouse_config"
sequence="10"
/>
</odoo> </odoo>

View File

@@ -1,41 +1,55 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<odoo> <odoo>
<record id="view_location_form" model="ir.ui.view"> <record id="view_location_form" model="ir.ui.view">
<field name="name">stock.location.form.tray.type</field> <field name="name">stock.location.form.tray.type</field>
<field name="model">stock.location</field> <field name="model">stock.location</field>
<field name="inherit_id" ref="stock.view_location_form"/> <field name="inherit_id" ref="stock.view_location_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<group name="additional_info" position="after"> <group name="additional_info" position="after">
<group string="Tray" name="tray"> <group string="Tray" name="tray">
<field name="tray_type_id" <field
attrs="{'invisible': [('cell_in_tray_type_id', '!=', False)]}"/> name="tray_type_id"
<field name="cell_name_format" attrs="{'invisible': [('tray_type_id', '=', False)]}"/> attrs="{'invisible': [('cell_in_tray_type_id', '!=', False)]}"
<field name="cell_in_tray_type_id" />
attrs="{'invisible': [('cell_in_tray_type_id', '=', False)]}"/> <field
<field name="tray_matrix" name="cell_name_format"
widget="location_tray_matrix" attrs="{'invisible': [('tray_type_id', '=', False)]}"
attrs="{'invisible': [('tray_type_id', '=', False), ('cell_in_tray_type_id', '=', False)]}" />
options="{'click_action': 'action_tray_matrix_click'}" <field
name="cell_in_tray_type_id"
attrs="{'invisible': [('cell_in_tray_type_id', '=', False)]}"
/>
<field
name="tray_matrix"
widget="location_tray_matrix"
attrs="{'invisible': [('tray_type_id', '=', False), ('cell_in_tray_type_id', '=', False)]}"
options="{'click_action': 'action_tray_matrix_click'}"
/>
<field
name="posx"
attrs="{'readonly': [('cell_in_tray_type_id', '!=', False)], 'invisible': ['|', ('cell_in_tray_type_id', '=', False), ('tray_type_id', '=', True)]}"
/>
<field
name="posy"
attrs="{'readonly': [('cell_in_tray_type_id', '!=', False)], 'invisible': ['|', ('cell_in_tray_type_id', '=', False), ('tray_type_id', '=', True)]}"
/>
<field
name="posz"
attrs="{'readonly': [('cell_in_tray_type_id', '!=', False)], 'invisible': ['|', ('cell_in_tray_type_id', '=', False), ('tray_type_id', '=', True)]}"
/> />
<field name="posx" attrs="{'readonly': [('cell_in_tray_type_id', '!=', False)], 'invisible': ['|', ('cell_in_tray_type_id', '=', False), ('tray_type_id', '=', True)]}" />
<field name="posy" attrs="{'readonly': [('cell_in_tray_type_id', '!=', False)], 'invisible': ['|', ('cell_in_tray_type_id', '=', False), ('tray_type_id', '=', True)]}" />
<field name="posz" attrs="{'readonly': [('cell_in_tray_type_id', '!=', False)], 'invisible': ['|', ('cell_in_tray_type_id', '=', False), ('tray_type_id', '=', True)]}" />
</group> </group>
</group> </group>
</field> </field>
</record> </record>
<record id="view_location_search" model="ir.ui.view"> <record id="view_location_search" model="ir.ui.view">
<field name="name">stock.location.search.tray.type</field> <field name="name">stock.location.search.tray.type</field>
<field name="model">stock.location</field> <field name="model">stock.location</field>
<field name="inherit_id" ref="stock.view_location_search"/> <field name="inherit_id" ref="stock.view_location_search" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="location_id" position="after"> <field name="location_id" position="after">
<separator/> <separator />
<field name="tray_type_id"/> <field name="tray_type_id" />
</field> </field>
</field> </field>
</record> </record>
</odoo> </odoo>

View File

@@ -1,59 +1,60 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<odoo> <odoo>
<record id="view_stock_move_line_operation_tree" model="ir.ui.view"> <record id="view_stock_move_line_operation_tree" model="ir.ui.view">
<field name="name">stock.move.line.operations.tree.tray.type</field> <field name="name">stock.move.line.operations.tree.tray.type</field>
<field name="model">stock.move.line</field> <field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_stock_move_line_operation_tree" /> <field name="inherit_id" ref="stock.view_stock_move_line_operation_tree" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="location_id" position="after"> <field name="location_id" position="after">
<field name="tray_source_matrix" invisible="1"/> <field name="tray_source_matrix" invisible="1" />
<button name="action_show_source_tray" <button
string="Show Source Tray" name="action_show_source_tray"
type="object" icon="fa-th" string="Show Source Tray"
attrs="{'invisible': [('tray_source_matrix', '=', {})]}" type="object"
invisible="not context.get('show_source_location')" icon="fa-th"
groups="stock.group_stock_multi_locations" attrs="{'invisible': [('tray_source_matrix', '=', {})]}"
invisible="not context.get('show_source_location')"
groups="stock.group_stock_multi_locations"
/> />
</field> </field>
<field name="location_dest_id" position="after"> <field name="location_dest_id" position="after">
<field name="tray_dest_matrix" invisible="1"/> <field name="tray_dest_matrix" invisible="1" />
<button name="action_show_dest_tray" <button
string="Show Destination Tray" name="action_show_dest_tray"
type="object" icon="fa-th" string="Show Destination Tray"
attrs="{'invisible': [('tray_dest_matrix', '=', {})]}" type="object"
invisible="not context.get('show_destination_location')" icon="fa-th"
groups="stock.group_stock_multi_locations" attrs="{'invisible': [('tray_dest_matrix', '=', {})]}"
invisible="not context.get('show_destination_location')"
groups="stock.group_stock_multi_locations"
/> />
</field> </field>
</field> </field>
</record> </record>
<record id="view_stock_move_line_tray" model="ir.ui.view"> <record id="view_stock_move_line_tray" model="ir.ui.view">
<field name="name">stock.move.line.tray</field> <field name="name">stock.move.line.tray</field>
<field name="model">stock.move.line</field> <field name="model">stock.move.line</field>
<field name="priority">1000</field> <field name="priority">1000</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Tray" create="0" edit="0" delete="0"> <form string="Tray" create="0" edit="0" delete="0">
<group name="source_tray" <group
invisible="not context.get('show_source_tray')"> name="source_tray"
invisible="not context.get('show_source_tray')"
>
<field name="location_id" readonly="1" /> <field name="location_id" readonly="1" />
<field name="tray_source_matrix" <field name="tray_source_matrix" widget="location_tray_matrix" />
widget="location_tray_matrix" />
</group> </group>
<group name="destination_tray" <group
invisible="not context.get('show_dest_tray')"> name="destination_tray"
invisible="not context.get('show_dest_tray')"
>
<field name="location_dest_id" readonly="1" /> <field name="location_dest_id" readonly="1" />
<field name="tray_dest_matrix" <field name="tray_dest_matrix" widget="location_tray_matrix" />
widget="location_tray_matrix" />
</group> </group>
<footer> <footer>
<button string="Close" <button string="Close" class="btn-secondary" special="cancel" />
class="btn-secondary"
special="cancel" />
</footer> </footer>
</form> </form>
</field> </field>
</record> </record>
</odoo> </odoo>