diff --git a/stock_move_location/README.rst b/stock_move_location/README.rst index c25c79b4f..8b62edec7 100644 --- a/stock_move_location/README.rst +++ b/stock_move_location/README.rst @@ -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 * Mykhailo Panarin +* Sergio Teruel Maintainers ~~~~~~~~~~~ diff --git a/stock_move_location/__manifest__.py b/stock_move_location/__manifest__.py index a92ab10db..c5df55d68 100644 --- a/stock_move_location/__manifest__.py +++ b/stock_move_location/__manifest__.py @@ -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', ], } diff --git a/stock_move_location/data/stock_quant_view.xml b/stock_move_location/data/stock_quant_view.xml new file mode 100755 index 000000000..d55d803b1 --- /dev/null +++ b/stock_move_location/data/stock_quant_view.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/stock_move_location/i18n/stock_move_location.pot b/stock_move_location/i18n/stock_move_location.pot index fc500ae93..0480333d7 100644 --- a/stock_move_location/i18n/stock_move_location.pot +++ b/stock_move_location/i18n/stock_move_location.pot @@ -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 diff --git a/stock_move_location/readme/CONTRIBUTORS.rst b/stock_move_location/readme/CONTRIBUTORS.rst index 012a547fe..42ac7b946 100644 --- a/stock_move_location/readme/CONTRIBUTORS.rst +++ b/stock_move_location/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Mathieu Vatel * Mykhailo Panarin +* Sergio Teruel diff --git a/stock_move_location/readme/DESCRIPTION.rst b/stock_move_location/readme/DESCRIPTION.rst index 7b0eeb0ee..7eed585fd 100644 --- a/stock_move_location/readme/DESCRIPTION.rst +++ b/stock_move_location/readme/DESCRIPTION.rst @@ -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. diff --git a/stock_move_location/readme/USAGE.rst b/stock_move_location/readme/USAGE.rst index 19e071798..680d2db92 100644 --- a/stock_move_location/readme/USAGE.rst +++ b/stock_move_location/readme/USAGE.rst @@ -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 diff --git a/stock_move_location/static/description/index.html b/stock_move_location/static/description/index.html index 85911da44..bb24d4588 100644 --- a/stock_move_location/static/description/index.html +++ b/stock_move_location/static/description/index.html @@ -368,7 +368,8 @@ ul.auto-toc { !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

-

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

    @@ -397,6 +398,13 @@ 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
  • +

Known issues / Roadmap

@@ -429,6 +437,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
diff --git a/stock_move_location/tests/test_move_location.py b/stock_move_location/tests/test_move_location.py index 3ac3ccd8e..07271f0ce 100644 --- a/stock_move_location/tests/test_move_location.py +++ b/stock_move_location/tests/test_move_location.py @@ -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) diff --git a/stock_move_location/wizard/stock_move_location.py b/stock_move_location/wizard/stock_move_location.py index a83414e67..046b5393e 100644 --- a/stock_move_location/wizard/stock_move_location.py +++ b/stock_move_location/wizard/stock_move_location.py @@ -1,8 +1,10 @@ # Copyright (C) 2011 Julius Network Solutions SARL # Copyright 2018 Camptocamp SA +# Copyright 2019 Sergio Teruel - Tecnativa # 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')] diff --git a/stock_move_location/wizard/stock_move_location.xml b/stock_move_location/wizard/stock_move_location.xml index cb5af3692..32f4399ca 100755 --- a/stock_move_location/wizard/stock_move_location.xml +++ b/stock_move_location/wizard/stock_move_location.xml @@ -8,10 +8,10 @@
- + - +