mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[11.0][IMP] stock_move_location: Allow move products from one location to another directly from selected quants
This commit is contained in:
committed by
João Marques
parent
5de891e266
commit
9bb0ce24cd
@@ -25,7 +25,8 @@ Move Stock Location
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module allows to move entire location of products from one place to another
|
||||
This module allows to move entire location of products from one place to
|
||||
another and move only selected quants.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
@@ -46,6 +47,14 @@ Usage
|
||||
* Products will be moved and a form view of picking that did that will show up
|
||||
* If "PLANNED TRANSFER" is used - the picking won't be validated automatically
|
||||
|
||||
If you want to transfer a full quant:
|
||||
|
||||
* Go to `Inventory > Master Data > Products` and click "On hand" smart button
|
||||
or `Inventory > Reporting > Inventory`, the quants view will be
|
||||
opened.
|
||||
|
||||
* Select the quants which you want move to another location
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
@@ -79,6 +88,7 @@ Contributors
|
||||
|
||||
* Mathieu Vatel <mathieu@julius.fr>
|
||||
* Mykhailo Panarin <m.panarin@mobilunity.com>
|
||||
* Sergio Teruel <sergio.teruel@tecnativa.com>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
{
|
||||
"name": "Move Stock Location",
|
||||
"version": "11.0.1.0.1",
|
||||
"version": "11.0.1.1.0",
|
||||
"author": "Julius Network Solutions, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"summary": "This module allows to move all stock "
|
||||
@@ -16,6 +16,7 @@
|
||||
],
|
||||
"category": "Stock",
|
||||
"data": [
|
||||
'data/stock_quant_view.xml',
|
||||
'wizard/stock_move_location.xml',
|
||||
],
|
||||
}
|
||||
|
||||
16
stock_move_location/data/stock_quant_view.xml
Executable file
16
stock_move_location/data/stock_quant_view.xml
Executable file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- To move quants directly from qants views -->
|
||||
<act_window id="wiz_stock_quant_location_action"
|
||||
name="Move to location..."
|
||||
res_model="wiz.stock.move.location"
|
||||
src_model="stock.quant"
|
||||
view_mode="form"
|
||||
context="{'origin_location_disable': True}"
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
groups="stock.group_stock_user"
|
||||
/>
|
||||
|
||||
</odoo>
|
||||
@@ -128,6 +128,11 @@ msgstr ""
|
||||
msgid "Move quantity can not exceed max quantity or be negative"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_move_location
|
||||
#: model:ir.actions.act_window,name:stock_move_location.wiz_stock_quant_location_action
|
||||
msgid "Move to location..."
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_move_location
|
||||
#: model:ir.model.fields,field_description:stock_move_location.field_wiz_stock_move_location_line_origin_location_id
|
||||
#: model:ir.model.fields,field_description:stock_move_location.field_wiz_stock_move_location_origin_location_id
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
* Mathieu Vatel <mathieu@julius.fr>
|
||||
* Mykhailo Panarin <m.panarin@mobilunity.com>
|
||||
* Sergio Teruel <sergio.teruel@tecnativa.com>
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
This module allows to move entire location of products from one place to another
|
||||
This module allows to move entire location of products from one place to
|
||||
another and move only selected quants.
|
||||
|
||||
@@ -8,3 +8,11 @@
|
||||
it will move only the available quantity at the button press
|
||||
* Products will be moved and a form view of picking that did that will show up
|
||||
* If "PLANNED TRANSFER" is used - the picking won't be validated automatically
|
||||
|
||||
If you want to transfer a full quant:
|
||||
|
||||
* Go to `Inventory > Master Data > Products` and click "On hand" smart button
|
||||
or `Inventory > Reporting > Inventory`, the quants view will be
|
||||
opened.
|
||||
|
||||
* Select the quants which you want move to another location
|
||||
|
||||
@@ -368,7 +368,8 @@ ul.auto-toc {
|
||||
!! 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/11.0/stock_move_location"><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-11-0/stock-logistics-warehouse-11-0-stock_move_location"><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/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module allows to move entire location of products from one place to another</p>
|
||||
<p>This module allows to move entire location of products from one place to
|
||||
another and move only selected quants.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
@@ -397,6 +398,13 @@ it will move only the available quantity at the button press</li>
|
||||
<li>Products will be moved and a form view of picking that did that will show up</li>
|
||||
<li>If “PLANNED TRANSFER” is used - the picking won’t be validated automatically</li>
|
||||
</ul>
|
||||
<p>If you want to transfer a full quant:</p>
|
||||
<ul class="simple">
|
||||
<li>Go to <cite>Inventory > Master Data > Products</cite> and click “On hand” smart button
|
||||
or <cite>Inventory > Reporting > Inventory</cite>, the quants view will be
|
||||
opened.</li>
|
||||
<li>Select the quants which you want move to another location</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="known-issues-roadmap">
|
||||
<h1><a class="toc-backref" href="#id2">Known issues / Roadmap</a></h1>
|
||||
@@ -429,6 +437,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<ul class="simple">
|
||||
<li>Mathieu Vatel <<a class="reference external" href="mailto:mathieu@julius.fr">mathieu@julius.fr</a>></li>
|
||||
<li>Mykhailo Panarin <<a class="reference external" href="mailto:m.panarin@mobilunity.com">m.panarin@mobilunity.com</a>></li>
|
||||
<li>Sergio Teruel <<a class="reference external" href="mailto:sergio.teruel@tecnativa.com">sergio.teruel@tecnativa.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
|
||||
@@ -88,7 +88,12 @@ class TestMoveLocation(TestsCommon):
|
||||
wizard = self._create_wizard(self.internal_loc_1, self.internal_loc_2)
|
||||
wizard.add_lines()
|
||||
self.assertEqual(len(wizard.stock_move_location_line_ids), 4)
|
||||
wizard._onchange_locations()
|
||||
wizard._onchange_destination_location_id()
|
||||
self.assertEqual(len(wizard.stock_move_location_line_ids), 4)
|
||||
dest_location_line = wizard.stock_move_location_line_ids.mapped(
|
||||
'destination_location_id')
|
||||
self.assertEqual(dest_location_line, wizard.destination_location_id)
|
||||
wizard._onchange_origin_location_id()
|
||||
self.assertEqual(len(wizard.stock_move_location_line_ids), 0)
|
||||
|
||||
def test_planned_transfer(self):
|
||||
@@ -103,3 +108,24 @@ class TestMoveLocation(TestsCommon):
|
||||
sorted(picking.move_line_ids.mapped("qty_done")),
|
||||
[1, 1, 1, 123],
|
||||
)
|
||||
|
||||
def test_quant_transfer(self):
|
||||
"""Test quants transfer."""
|
||||
quants = self.product_lots.stock_quant_ids
|
||||
wizard = self.wizard_obj.with_context(
|
||||
active_model='stock.quant',
|
||||
active_ids=quants.ids,
|
||||
origin_location_disable=True
|
||||
).create({
|
||||
"origin_location_id": quants[:1].location_id.id,
|
||||
"destination_location_id": self.internal_loc_2.id,
|
||||
})
|
||||
lines = wizard.stock_move_location_line_ids
|
||||
self.assertEqual(len(lines), 3)
|
||||
wizard.destination_location_id = self.internal_loc_1
|
||||
wizard._onchange_destination_location_id()
|
||||
self.assertEqual(
|
||||
lines.mapped('destination_location_id'), self.internal_loc_1)
|
||||
wizard.origin_location_id = self.internal_loc_2
|
||||
wizard._onchange_destination_location_id()
|
||||
self.assertEqual(len(lines), 3)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr>
|
||||
# Copyright 2018 Camptocamp SA
|
||||
# Copyright 2019 Sergio Teruel - Tecnativa <sergio.teruel@tecnativa.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.fields import first
|
||||
|
||||
|
||||
class StockMoveLocationWizard(models.TransientModel):
|
||||
@@ -30,19 +32,38 @@ class StockMoveLocationWizard(models.TransientModel):
|
||||
comodel_name="stock.picking",
|
||||
)
|
||||
|
||||
@api.onchange('origin_location_id', 'destination_location_id')
|
||||
def _onchange_locations(self):
|
||||
self._clear_lines()
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super().default_get(fields)
|
||||
if self.env.context.get('active_model', False) != 'stock.quant':
|
||||
return res
|
||||
# Load data directly from quants
|
||||
quants = self.env['stock.quant'].browse(
|
||||
self.env.context.get('active_ids', False))
|
||||
res['stock_move_location_line_ids'] = [(0, 0, {
|
||||
'product_id': quant.product_id.id,
|
||||
'move_quantity': quant.quantity,
|
||||
'max_quantity': quant.quantity,
|
||||
'origin_location_id': quant.location_id.id,
|
||||
'lot_id': quant.lot_id.id,
|
||||
'product_uom_id': quant.product_uom_id.id,
|
||||
'custom': False,
|
||||
}) for quant in quants]
|
||||
res['origin_location_id'] = first(quants).location_id.id
|
||||
return res
|
||||
|
||||
@api.onchange('origin_location_id')
|
||||
def _onchange_origin_location_id(self):
|
||||
if not self.env.context.get('origin_location_disable', False):
|
||||
self._clear_lines()
|
||||
|
||||
@api.onchange('destination_location_id')
|
||||
def _onchange_destination_location_id(self):
|
||||
for line in self.stock_move_location_line_ids:
|
||||
line.destination_location_id = self.destination_location_id
|
||||
|
||||
def _clear_lines(self):
|
||||
origin = self.origin_location_id
|
||||
destination = self.destination_location_id
|
||||
# there is `invalidate_cache` call inside the unlink
|
||||
# which will clear the wizard - not cool.
|
||||
# we have to keep the values somehow
|
||||
self.stock_move_location_line_ids.unlink()
|
||||
self.origin_location_id = origin
|
||||
self.destination_location_id = destination
|
||||
self.stock_move_location_line_ids = False
|
||||
|
||||
def _get_locations_domain(self):
|
||||
return [('usage', '=', 'internal')]
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
<form>
|
||||
<sheet>
|
||||
<group name="main">
|
||||
<field name="origin_location_id"/>
|
||||
<field name="origin_location_id" invisible="context.get('origin_location_disable', False)"/>
|
||||
<field name="destination_location_id"/>
|
||||
</group>
|
||||
<group name="button">
|
||||
<group name="button" invisible="context.get('origin_location_disable', False)">
|
||||
<button name="add_lines" string="Add all" type="object" class="btn-primary"/>
|
||||
<button name="clear_lines" string="Clear all" type="object" class="btn-primary"/>
|
||||
</group>
|
||||
@@ -25,7 +25,7 @@
|
||||
<field name="lot_id" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}" groups="stock.group_production_lot" options="{'no_create': True}"/>
|
||||
<field name="move_quantity"/>
|
||||
<field name="custom" invisible="1" />
|
||||
<field name="max_quantity" attrs="{'readonly': [('custom', '!=', True)]}" />
|
||||
<field name="max_quantity" attrs="{'readonly': [('custom', '!=', True)]}" force_save="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user