mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
Add tray matrix on stock move lines
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
'views/stock_location_views.xml',
|
'views/stock_location_views.xml',
|
||||||
'views/stock_location_tray_type_views.xml',
|
'views/stock_location_tray_type_views.xml',
|
||||||
'views/stock_location_tray_templates.xml',
|
'views/stock_location_tray_templates.xml',
|
||||||
|
'views/stock_move_line_views.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
from . import stock_location
|
from . import stock_location
|
||||||
from . import stock_location_tray_type
|
from . import stock_location_tray_type
|
||||||
|
from . import stock_move_line
|
||||||
|
|||||||
@@ -51,10 +51,18 @@ class StockLocation(models.Model):
|
|||||||
def _compute_tray_matrix(self):
|
def _compute_tray_matrix(self):
|
||||||
for location in self:
|
for location in self:
|
||||||
if not (location.tray_type_id or location.cell_in_tray_type_id):
|
if not (location.tray_type_id or location.cell_in_tray_type_id):
|
||||||
|
location.tray_matrix = {}
|
||||||
continue
|
continue
|
||||||
location.tray_matrix = {
|
location.tray_matrix = location._tray_matrix_for_widget()
|
||||||
"selected": location._tray_cell_coords(),
|
|
||||||
"cells": location._tray_cell_matrix(),
|
def _tray_matrix_for_widget(self):
|
||||||
|
selected = self._tray_cell_coords()
|
||||||
|
cells = self._tray_cell_matrix()
|
||||||
|
return {
|
||||||
|
# x, y: position of the selected cell
|
||||||
|
"selected": selected,
|
||||||
|
# 0 is empty, 1 is not
|
||||||
|
"cells": cells,
|
||||||
}
|
}
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
|||||||
52
stock_location_tray/models/stock_move_line.py
Normal file
52
stock_location_tray/models/stock_move_line.py
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Copyright 2019 Camptocamp SA
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
class StockMoveLine(models.Model):
|
||||||
|
_inherit = "stock.move.line"
|
||||||
|
|
||||||
|
tray_source_matrix = Serialized(
|
||||||
|
string="Source Cell", compute="_compute_tray_matrix"
|
||||||
|
)
|
||||||
|
tray_dest_matrix = Serialized(
|
||||||
|
string="Destination Cell", compute="_compute_tray_matrix"
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends("location_id", "location_dest_id")
|
||||||
|
def _compute_tray_matrix(self):
|
||||||
|
for record in self:
|
||||||
|
record.tray_source_matrix = record.location_id.tray_matrix
|
||||||
|
record.tray_dest_matrix = record.location_dest_id.tray_matrix
|
||||||
|
|
||||||
|
def _action_show_tray(self, location_from):
|
||||||
|
assert location_from in ("source", "dest")
|
||||||
|
self.ensure_one()
|
||||||
|
view = self.env.ref("stock_location_tray.view_stock_move_line_tray")
|
||||||
|
context = self.env.context.copy()
|
||||||
|
if location_from == "source":
|
||||||
|
name = _("Source Tray")
|
||||||
|
context["show_source_tray"] = True
|
||||||
|
else:
|
||||||
|
name = _("Destination Tray")
|
||||||
|
context["show_dest_tray"] = True
|
||||||
|
return {
|
||||||
|
"name": name,
|
||||||
|
"type": "ir.actions.act_window",
|
||||||
|
"view_type": "form",
|
||||||
|
"view_mode": "form",
|
||||||
|
"res_model": "stock.move.line",
|
||||||
|
"views": [(view.id, "form")],
|
||||||
|
"view_id": view.id,
|
||||||
|
"target": "new",
|
||||||
|
"res_id": self.id,
|
||||||
|
"context": context,
|
||||||
|
}
|
||||||
|
|
||||||
|
def action_show_source_tray(self):
|
||||||
|
return self._action_show_tray("source")
|
||||||
|
|
||||||
|
def action_show_dest_tray(self):
|
||||||
|
return self._action_show_tray("dest")
|
||||||
5
stock_location_tray/readme/ROADMAP.rst
Normal file
5
stock_location_tray/readme/ROADMAP.rst
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
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.
|
||||||
59
stock_location_tray/views/stock_move_line_views.xml
Normal file
59
stock_location_tray/views/stock_move_line_views.xml
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<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="model">stock.move.line</field>
|
||||||
|
<field name="inherit_id" ref="stock.view_stock_move_line_operation_tree" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="location_id" position="after">
|
||||||
|
<field name="tray_source_matrix" invisible="1"/>
|
||||||
|
<button name="action_show_source_tray"
|
||||||
|
string="Show Source Tray"
|
||||||
|
type="object" icon="fa-th"
|
||||||
|
attrs="{'invisible': [('tray_source_matrix', '=', {})]}"
|
||||||
|
invisible="not context.get('show_source_location')"
|
||||||
|
groups="stock.group_stock_multi_locations"
|
||||||
|
/>
|
||||||
|
</field>
|
||||||
|
<field name="location_dest_id" position="after">
|
||||||
|
<field name="tray_dest_matrix" invisible="1"/>
|
||||||
|
<button name="action_show_dest_tray"
|
||||||
|
string="Show Destination Tray"
|
||||||
|
type="object" icon="fa-th"
|
||||||
|
attrs="{'invisible': [('tray_dest_matrix', '=', {})]}"
|
||||||
|
invisible="not context.get('show_destination_location')"
|
||||||
|
groups="stock.group_stock_multi_locations"
|
||||||
|
/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_stock_move_line_tray" model="ir.ui.view">
|
||||||
|
<field name="name">stock.move.line.tray</field>
|
||||||
|
<field name="model">stock.move.line</field>
|
||||||
|
<field name="priority">1000</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Tray" create="0" edit="0" delete="0">
|
||||||
|
<group name="source_tray"
|
||||||
|
invisible="not context.get('show_source_tray')">
|
||||||
|
<field name="location_id" readonly="1" />
|
||||||
|
<field name="tray_source_matrix"
|
||||||
|
widget="location_tray_matrix" />
|
||||||
|
</group>
|
||||||
|
<group name="destination_tray"
|
||||||
|
invisible="not context.get('show_dest_tray')">
|
||||||
|
<field name="location_dest_id" readonly="1" />
|
||||||
|
<field name="tray_dest_matrix"
|
||||||
|
widget="location_tray_matrix" />
|
||||||
|
</group>
|
||||||
|
<footer>
|
||||||
|
<button string="Close"
|
||||||
|
class="btn-secondary"
|
||||||
|
special="cancel" />
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user