mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
Migrate stock_location_tray to 13.0
This commit is contained in:
@@ -14,13 +14,13 @@ Location Trays
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_location_tray
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_location_tray
|
||||
:alt: OCA/stock-logistics-warehouse
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_location_tray
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_location_tray
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/153/12.0
|
||||
:target: https://runbot.odoo-community.org/runbot/153/13.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@@ -30,7 +30,7 @@ A tray type defines a number of columns and rows.
|
||||
A location with a tray type becomes a tray, and sub-locations are automatically
|
||||
created according to the columns and rows of the tray type
|
||||
|
||||
.. figure:: https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/12.0/stock_location_tray/static/description/location-tray.png
|
||||
.. figure:: https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/13.0/stock_location_tray/static/description/location-tray.png
|
||||
:alt: Location Tray
|
||||
:width: 600 px
|
||||
|
||||
@@ -68,13 +68,22 @@ on the new tray type.
|
||||
The matrix widget on Tray locations can be clicked to reach a sub-location.
|
||||
Blue squares represent the locations that contain goods.
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
The buttons on operations opens a view with the tray matrix to show operators
|
||||
where to pick/put goods. The issue is that Odoo allows only one modal popup
|
||||
to be open at a time. The tray matrix replaces the operations window. We have
|
||||
to find a way to prevent this. The tray matrix could be displayed through a
|
||||
tooltip maybe, if we find how to render a widget in a tooltip.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_location_tray%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_location_tray%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
@@ -104,6 +113,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_location_tray>`_ project on GitHub.
|
||||
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_location_tray>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -1,27 +1,21 @@
|
||||
# Copyright 2019 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
'name': 'Location Trays',
|
||||
'summary': 'Organize a location as a matrix of cells',
|
||||
'version': '12.0.1.0.0',
|
||||
'category': 'Stock',
|
||||
'author': 'Camptocamp, Odoo Community Association (OCA)',
|
||||
'license': 'AGPL-3',
|
||||
'depends': [
|
||||
'stock',
|
||||
'base_sparse_field',
|
||||
"name": "Location Trays",
|
||||
"summary": "Organize a location as a matrix of cells",
|
||||
"version": "13.0.1.0.0",
|
||||
"category": "Stock",
|
||||
"author": "Camptocamp, Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"depends": ["stock", "base_sparse_field"],
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
"demo": ["demo/stock_location_tray_type_demo.xml", "demo/stock_location_demo.xml"],
|
||||
"data": [
|
||||
"views/stock_location_views.xml",
|
||||
"views/stock_location_tray_type_views.xml",
|
||||
"views/stock_location_tray_templates.xml",
|
||||
"views/stock_move_line_views.xml",
|
||||
"security/ir.model.access.csv",
|
||||
],
|
||||
'website': 'https://github.com/OCA/stock-logistics-warehouse',
|
||||
'demo': [
|
||||
'demo/stock_location_tray_type_demo.xml',
|
||||
'demo/stock_location_demo.xml',
|
||||
],
|
||||
'data': [
|
||||
'views/stock_location_views.xml',
|
||||
'views/stock_location_tray_type_views.xml',
|
||||
'views/stock_location_tray_templates.xml',
|
||||
'views/stock_move_line_views.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'installable': True,
|
||||
"installable": True,
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
from odoo import _, api, exceptions, fields, models
|
||||
|
||||
from odoo.addons.base_sparse_field.models.fields import Serialized
|
||||
|
||||
|
||||
@@ -13,9 +15,7 @@ class StockLocation(models.Model):
|
||||
comodel_name="stock.location.tray.type", ondelete="restrict"
|
||||
)
|
||||
cell_in_tray_type_id = fields.Many2one(
|
||||
string="Cell Tray Type",
|
||||
related="location_id.tray_type_id",
|
||||
readonly=True,
|
||||
string="Cell Tray Type", related="location_id.tray_type_id", readonly=True
|
||||
)
|
||||
tray_cell_contains_stock = fields.Boolean(
|
||||
compute="_compute_tray_cell_contains_stock",
|
||||
@@ -30,7 +30,7 @@ class StockLocation(models.Model):
|
||||
" 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/2/library/string.html#formatstrings",
|
||||
" https://docs.python.org/3/library/string.html#formatstrings",
|
||||
)
|
||||
|
||||
def _default_cell_name_format(self):
|
||||
@@ -40,14 +40,14 @@ class StockLocation(models.Model):
|
||||
def _compute_tray_cell_contains_stock(self):
|
||||
for location in self:
|
||||
if not location.cell_in_tray_type_id:
|
||||
# we skip the others only for performance
|
||||
# Not a tray cell so the value is irrelevant,
|
||||
# best to skip them for performance.
|
||||
location.tray_cell_contains_stock = False
|
||||
continue
|
||||
quants = location.quant_ids.filtered(lambda r: r.quantity > 0)
|
||||
location.tray_cell_contains_stock = bool(quants)
|
||||
|
||||
@api.depends(
|
||||
"quant_ids.quantity", "tray_type_id", "location_id.tray_type_id"
|
||||
)
|
||||
@api.depends("quant_ids.quantity", "tray_type_id", "location_id.tray_type_id")
|
||||
def _compute_tray_matrix(self):
|
||||
for location in self:
|
||||
if not (location.tray_type_id or location.cell_in_tray_type_id):
|
||||
@@ -65,7 +65,6 @@ class StockLocation(models.Model):
|
||||
"cells": cells,
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def action_tray_matrix_click(self, coordX, coordY):
|
||||
self.ensure_one()
|
||||
if self.cell_in_tray_type_id:
|
||||
@@ -104,14 +103,10 @@ class StockLocation(models.Model):
|
||||
def _check_before_add_tray_type(self):
|
||||
if not self.tray_type_id and self.child_ids:
|
||||
raise exceptions.UserError(
|
||||
_(
|
||||
"Location %s has sub-locations, it cannot be converted"
|
||||
" to a tray."
|
||||
)
|
||||
_("Location %s has sub-locations, it cannot be converted" " to a tray.")
|
||||
% (self.display_name)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
for location in self:
|
||||
trays_to_update = False
|
||||
@@ -201,7 +196,6 @@ class StockLocation(models.Model):
|
||||
# using format_map allows to have missing replacement strings
|
||||
return template.format_map(defaultdict(str, x=x, y=y, z=z))
|
||||
|
||||
@api.multi
|
||||
def _update_tray_sublocations(self):
|
||||
values = []
|
||||
for location in self:
|
||||
@@ -213,10 +207,7 @@ class StockLocation(models.Model):
|
||||
# trap this check (_tray_check_active) to display a
|
||||
# contextual error message
|
||||
raise exceptions.UserError(
|
||||
_(
|
||||
"Trays cannot be modified when "
|
||||
"they contain products."
|
||||
)
|
||||
_("Trays cannot be modified when " "they contain products.")
|
||||
)
|
||||
|
||||
if not tray_type:
|
||||
@@ -226,9 +217,7 @@ class StockLocation(models.Model):
|
||||
posz = location.posz or 0
|
||||
for row in range(1, tray_type.rows + 1):
|
||||
for col in range(1, tray_type.cols + 1):
|
||||
cell_name = location._format_tray_sublocation_name(
|
||||
col, row, posz
|
||||
)
|
||||
cell_name = location._format_tray_sublocation_name(col, row, posz)
|
||||
subloc_values = {
|
||||
"name": cell_name,
|
||||
"posx": col,
|
||||
@@ -241,7 +230,6 @@ class StockLocation(models.Model):
|
||||
if values:
|
||||
self.create(values)
|
||||
|
||||
@api.multi
|
||||
def _create_tray_xmlids(self, module):
|
||||
"""Create external IDs for generated cells
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
from odoo import _, api, exceptions, fields, models
|
||||
from odoo.osv import expression
|
||||
|
||||
from odoo.addons.base_sparse_field.models.fields import Serialized
|
||||
|
||||
|
||||
@@ -19,8 +20,8 @@ class StockLocationTrayType(models.Model):
|
||||
depth = fields.Integer(help="Depth of the tray in mm")
|
||||
height = fields.Integer(help="Height of the tray in mm")
|
||||
|
||||
width_per_cell = fields.Float(compute='_compute_width_per_cell')
|
||||
depth_per_cell = fields.Float(compute='_compute_depth_per_cell')
|
||||
width_per_cell = fields.Float(compute="_compute_width_per_cell")
|
||||
depth_per_cell = fields.Float(compute="_compute_depth_per_cell")
|
||||
|
||||
active = fields.Boolean(default=True)
|
||||
tray_matrix = Serialized(compute="_compute_tray_matrix")
|
||||
@@ -33,7 +34,7 @@ class StockLocationTrayType(models.Model):
|
||||
for record in self:
|
||||
width = record.width
|
||||
if not width:
|
||||
record.width_per_cell = 0.
|
||||
record.width_per_cell = 0.0
|
||||
continue
|
||||
record.width_per_cell = width / record.cols
|
||||
|
||||
@@ -42,7 +43,7 @@ class StockLocationTrayType(models.Model):
|
||||
for record in self:
|
||||
depth = record.depth
|
||||
if not depth:
|
||||
record.depth_per_cell = 0.
|
||||
record.depth_per_cell = 0.0
|
||||
continue
|
||||
record.depth_per_cell = depth / record.rows
|
||||
|
||||
@@ -56,7 +57,6 @@ class StockLocationTrayType(models.Model):
|
||||
cells = self._generate_cells_matrix(default_state=1)
|
||||
record.tray_matrix = {"selected": [], "cells": cells}
|
||||
|
||||
@api.model
|
||||
def _name_search(
|
||||
self, name, args=None, operator="ilike", limit=100, name_get_uid=None
|
||||
):
|
||||
@@ -65,9 +65,7 @@ class StockLocationTrayType(models.Model):
|
||||
if name:
|
||||
domain = ["|", ("name", operator, name), ("code", operator, name)]
|
||||
tray_ids = self._search(
|
||||
expression.AND([domain, args]),
|
||||
limit=limit,
|
||||
access_rights_uid=name_get_uid,
|
||||
expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid
|
||||
)
|
||||
return self.browse(tray_ids).name_get()
|
||||
|
||||
@@ -106,7 +104,6 @@ class StockLocationTrayType(models.Model):
|
||||
).format(record.name, "\n".join(location_bullets))
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def open_locations(self):
|
||||
action = self.env.ref("stock.action_location_form").read()[0]
|
||||
action["domain"] = [("tray_type_id", "in", self.ids)]
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, api, models
|
||||
|
||||
from odoo.addons.base_sparse_field.models.fields import Serialized
|
||||
|
||||
|
||||
|
||||
@@ -367,13 +367,13 @@ ul.auto-toc {
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_location_tray"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_location_tray"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_location_tray"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_location_tray"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>Add an optional Tray Type on Stock Locations.
|
||||
A tray type defines a number of columns and rows.
|
||||
A location with a tray type becomes a tray, and sub-locations are automatically
|
||||
created according to the columns and rows of the tray type</p>
|
||||
<div class="figure">
|
||||
<img alt="Location Tray" src="https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/12.0/stock_location_tray/static/description/location-tray.png" style="width: 600px;" />
|
||||
<img alt="Location Tray" src="https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/13.0/stock_location_tray/static/description/location-tray.png" style="width: 600px;" />
|
||||
</div>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
@@ -384,11 +384,12 @@ created according to the columns and rows of the tray type</p>
|
||||
<li><a class="reference internal" href="#locations" id="id4">Locations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="id5">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="id6">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="id7">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="id8">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="id9">Maintainers</a></li>
|
||||
<li><a class="reference internal" href="#known-issues-roadmap" id="id5">Known issues / Roadmap</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="id6">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="id7">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="id8">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="id9">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="id10">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -420,36 +421,44 @@ on the new tray type.</p>
|
||||
Blue squares represent the locations that contain goods.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="known-issues-roadmap">
|
||||
<h1><a class="toc-backref" href="#id5">Known issues / Roadmap</a></h1>
|
||||
<p>The buttons on operations opens a view with the tray matrix to show operators
|
||||
where to pick/put goods. The issue is that Odoo allows only one modal popup
|
||||
to be open at a time. The tray matrix replaces the operations window. We have
|
||||
to find a way to prevent this. The tray matrix could be displayed through a
|
||||
tooltip maybe, if we find how to render a widget in a tooltip.</p>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#id5">Bug Tracker</a></h1>
|
||||
<h1><a class="toc-backref" href="#id6">Bug Tracker</a></h1>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_location_tray%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_location_tray%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h1><a class="toc-backref" href="#id6">Credits</a></h1>
|
||||
<h1><a class="toc-backref" href="#id7">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#id7">Authors</a></h2>
|
||||
<h2><a class="toc-backref" href="#id8">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Camptocamp</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id8">Contributors</a></h2>
|
||||
<h2><a class="toc-backref" href="#id9">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Guewen Baconnier <<a class="reference external" href="mailto:guewen.baconnier@camptocamp.com">guewen.baconnier@camptocamp.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#id9">Maintainers</a></h2>
|
||||
<h2><a class="toc-backref" href="#id10">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_location_tray">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_location_tray">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -172,7 +172,7 @@ var LocationTrayMatrixField = DebouncedField.extend({
|
||||
*
|
||||
*/
|
||||
_renderInDOM: function () {
|
||||
this.canvas = this.$el.find('canvas').context;
|
||||
this.canvas = this.$el[0];
|
||||
var canvas = this.canvas;
|
||||
var ctx = canvas.getContext('2d');
|
||||
this.resizeCanvasToDisplaySize(ctx.canvas);
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
from . import test_location
|
||||
from . import test_tray_type
|
||||
|
||||
|
||||
@@ -8,32 +8,25 @@ class LocationTrayTypeCase(common.SavepointCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.stock_location = cls.env.ref('stock.stock_location_stock')
|
||||
cls.product = cls.env.ref(
|
||||
'product.product_delivery_02'
|
||||
)
|
||||
cls.tray_location = cls.env.ref(
|
||||
"stock_location_tray.stock_location_tray_demo"
|
||||
)
|
||||
cls.wh = cls.env.ref("stock.warehouse0")
|
||||
cls.stock_location = cls.env.ref("stock.stock_location_stock")
|
||||
cls.product = cls.env.ref("product.product_delivery_02")
|
||||
cls.tray_location = cls.env.ref("stock_location_tray.stock_location_tray_demo")
|
||||
cls.tray_type_small_8x = cls.env.ref(
|
||||
'stock_location_tray.stock_location_tray_type_small_8x'
|
||||
"stock_location_tray.stock_location_tray_type_small_8x"
|
||||
)
|
||||
cls.tray_type_small_32x = cls.env.ref(
|
||||
'stock_location_tray.stock_location_tray_type_small_32x'
|
||||
"stock_location_tray.stock_location_tray_type_small_32x"
|
||||
)
|
||||
|
||||
def _cell_for(self, tray, x=1, y=1):
|
||||
cell = self.env['stock.location'].search(
|
||||
[('location_id', '=', tray.id), ('posx', '=', x), ('posy', '=', y)]
|
||||
cell = self.env["stock.location"].search(
|
||||
[("location_id", "=", tray.id), ("posx", "=", x), ("posy", "=", y)]
|
||||
)
|
||||
self.assertEqual(
|
||||
len(cell),
|
||||
1,
|
||||
"Cell x{}y{} not found for {}".format(x, y, tray.name),
|
||||
len(cell), 1, "Cell x{}y{} not found for {}".format(x, y, tray.name)
|
||||
)
|
||||
return cell
|
||||
|
||||
def _update_quantity_in_cell(self, cell, product, quantity):
|
||||
self.env['stock.quant']._update_available_quantity(
|
||||
product, cell, quantity
|
||||
)
|
||||
self.env["stock.quant"]._update_available_quantity(product, cell, quantity)
|
||||
|
||||
@@ -18,9 +18,7 @@ class TestLocation(LocationTrayTypeCase):
|
||||
}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
len(tray_loc.child_ids), tray_type.cols * tray_type.rows # 8
|
||||
)
|
||||
self.assertEqual(len(tray_loc.child_ids), tray_type.cols * tray_type.rows) # 8
|
||||
self.assertTrue(
|
||||
all(
|
||||
subloc.cell_in_tray_type_id == tray_type
|
||||
@@ -29,9 +27,7 @@ class TestLocation(LocationTrayTypeCase):
|
||||
)
|
||||
|
||||
def test_tray_has_stock(self):
|
||||
cell = self.env.ref(
|
||||
"stock_location_tray.stock_location_tray_demo_x3y2"
|
||||
)
|
||||
cell = self.env.ref("stock_location_tray.stock_location_tray_demo_x3y2")
|
||||
self.assertFalse(cell.quant_ids)
|
||||
self.assertFalse(cell.tray_cell_contains_stock)
|
||||
self._update_quantity_in_cell(cell, self.product, 1)
|
||||
@@ -127,17 +123,13 @@ class TestLocation(LocationTrayTypeCase):
|
||||
)
|
||||
|
||||
def test_check_active_empty(self):
|
||||
cell = self.env.ref(
|
||||
"stock_location_tray.stock_location_tray_demo_x3y2"
|
||||
)
|
||||
cell = self.env.ref("stock_location_tray.stock_location_tray_demo_x3y2")
|
||||
self.assertFalse(cell.tray_cell_contains_stock)
|
||||
# allowed to archive empty cell
|
||||
cell.active = False
|
||||
|
||||
def test_check_active_not_empty(self):
|
||||
cell = self.env.ref(
|
||||
"stock_location_tray.stock_location_tray_demo_x3y2"
|
||||
)
|
||||
cell = self.env.ref("stock_location_tray.stock_location_tray_demo_x3y2")
|
||||
self._update_quantity_in_cell(cell, self.product, 1)
|
||||
self.assertTrue(cell.tray_cell_contains_stock)
|
||||
|
||||
@@ -151,13 +143,15 @@ class TestLocation(LocationTrayTypeCase):
|
||||
# restore state for the next test loop
|
||||
location.active = True
|
||||
location = location.location_id
|
||||
if location == self.wh.lot_stock_id:
|
||||
# we can't disable the Stock location anyway
|
||||
break
|
||||
|
||||
def test_change_tray_type_when_empty(self):
|
||||
tray_type = self.tray_type_small_32x
|
||||
self.tray_location.tray_type_id = tray_type
|
||||
self.assertEqual(
|
||||
len(self.tray_location.child_ids),
|
||||
tray_type.cols * tray_type.rows, # 32
|
||||
len(self.tray_location.child_ids), tray_type.cols * tray_type.rows # 32
|
||||
)
|
||||
|
||||
def test_change_tray_type_error_when_not_empty(self):
|
||||
@@ -170,15 +164,11 @@ class TestLocation(LocationTrayTypeCase):
|
||||
self.tray_location.tray_type_id = tray_type
|
||||
|
||||
def test_location_center_pos(self):
|
||||
cell = self.env.ref(
|
||||
"stock_location_tray.stock_location_tray_demo_x3y2"
|
||||
)
|
||||
cell = self.env.ref("stock_location_tray.stock_location_tray_demo_x3y2")
|
||||
tray_type = cell.cell_in_tray_type_id
|
||||
number_of_x = 4
|
||||
number_of_y = 2
|
||||
self.assertEqual(
|
||||
(number_of_x, number_of_y), (tray_type.cols, tray_type.rows)
|
||||
)
|
||||
self.assertEqual((number_of_x, number_of_y), (tray_type.cols, tray_type.rows))
|
||||
|
||||
total_width = 80
|
||||
total_depth = 30
|
||||
|
||||
@@ -11,27 +11,21 @@ class TestLocationTrayType(LocationTrayTypeCase):
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.used_tray_type = cls.env.ref(
|
||||
'stock_location_tray.stock_location_tray_type_large_16x'
|
||||
"stock_location_tray.stock_location_tray_type_large_16x"
|
||||
)
|
||||
cls.unused_tray_type = cls.env.ref(
|
||||
'stock_location_tray.stock_location_tray_type_small_16x_3'
|
||||
"stock_location_tray.stock_location_tray_type_small_16x_3"
|
||||
)
|
||||
|
||||
def test_tray_type(self):
|
||||
# any location created directly under the view is a shuttle
|
||||
tray_type = self.env['stock.location.tray.type'].create(
|
||||
{
|
||||
'name': 'Test Type',
|
||||
'code': '🐵',
|
||||
'usage': 'internal',
|
||||
'rows': 4,
|
||||
'cols': 6,
|
||||
}
|
||||
tray_type = self.env["stock.location.tray.type"].create(
|
||||
{"name": "Test Type", "code": "🐵", "rows": 4, "cols": 6}
|
||||
)
|
||||
self.assertEqual(
|
||||
tray_type.tray_matrix,
|
||||
{
|
||||
'selected': [], # no selection as this is the "model"
|
||||
"selected": [], # no selection as this is the "model"
|
||||
# a "full" matrix is generated for display on the UI
|
||||
# fmt: off
|
||||
'cells': [
|
||||
@@ -49,7 +43,7 @@ class TestLocationTrayType(LocationTrayTypeCase):
|
||||
location.tray_type_id = self.used_tray_type
|
||||
location = self.used_tray_type.location_ids
|
||||
self.assertTrue(location)
|
||||
message = 'cannot be archived.*{}.*'.format(location.name)
|
||||
message = "cannot be archived.*{}.*".format(location.name)
|
||||
# we cannot archive used ones
|
||||
with self.assertRaisesRegex(exceptions.ValidationError, message):
|
||||
self.used_tray_type.active = False
|
||||
@@ -61,7 +55,7 @@ class TestLocationTrayType(LocationTrayTypeCase):
|
||||
location.tray_type_id = self.used_tray_type
|
||||
location = self.used_tray_type.location_ids
|
||||
self.assertTrue(location)
|
||||
message = 'size cannot be changed.*{}.*'.format(location.name)
|
||||
message = "size cannot be changed.*{}.*".format(location.name)
|
||||
# we cannot modify size of used ones
|
||||
with self.assertRaisesRegex(exceptions.ValidationError, message):
|
||||
self.used_tray_type.rows = 10
|
||||
|
||||
@@ -12,14 +12,13 @@
|
||||
icon="fa-filter" name="open_locations"
|
||||
type="object"
|
||||
/>
|
||||
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive">
|
||||
<field name="active" widget="boolean_button" options='{"terminology": "archive"}'/>
|
||||
</button>
|
||||
</div>
|
||||
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
|
||||
<label for="name" class="oe_edit_only"/>
|
||||
<h1><field name="name"/></h1>
|
||||
<group>
|
||||
<group string="Tray Configuration" name="settings">
|
||||
<field name="active" invisible="1"/>
|
||||
<field name="code"/>
|
||||
<field name="rows"/>
|
||||
<field name="cols"/>
|
||||
@@ -77,7 +76,6 @@
|
||||
<field name="name">Location Tray Types</field>
|
||||
<field name="res_model">stock.location.tray.type</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_stock_location_tray_type_tree"/>
|
||||
<field name="search_view_id" ref="view_stock_location_tray_type_search"/>
|
||||
<field name="context"></field>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="model">stock.location</field>
|
||||
<field name="inherit_id" ref="stock.view_location_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="localization" position="after">
|
||||
<group name="additional_info" position="after">
|
||||
<group string="Tray" name="tray">
|
||||
<field name="tray_type_id"
|
||||
attrs="{'invisible': [('cell_in_tray_type_id', '!=', False)]}"/>
|
||||
@@ -18,18 +18,11 @@
|
||||
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)]}" />
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<field name="posx" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('cell_in_tray_type_id', '!=', False)]}</attribute>
|
||||
</field>
|
||||
<field name="posy" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('cell_in_tray_type_id', '!=', False)]}</attribute>
|
||||
</field>
|
||||
<field name="posz" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('cell_in_tray_type_id', '!=', False)]}</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user