diff --git a/stock_move_location/__manifest__.py b/stock_move_location/__manifest__.py index d9b725fc5..a92ab10db 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.0", + "version": "11.0.1.0.1", "author": "Julius Network Solutions, " "Odoo Community Association (OCA)", "summary": "This module allows to move all stock " diff --git a/stock_move_location/static/description/icon.png b/stock_move_location/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_move_location/static/description/icon.png differ diff --git a/stock_move_location/tests/test_move_location.py b/stock_move_location/tests/test_move_location.py index 128a771fb..3ac3ccd8e 100644 --- a/stock_move_location/tests/test_move_location.py +++ b/stock_move_location/tests/test_move_location.py @@ -30,10 +30,10 @@ class TestMoveLocation(TestsCommon): self.product_lots, self.internal_loc_1, 0, self.lot1, ) self.check_product_amount( - self.product_lots, self.internal_loc_1, 0, self.lot1, + self.product_lots, self.internal_loc_1, 0, self.lot2, ) self.check_product_amount( - self.product_lots, self.internal_loc_1, 0, self.lot1, + self.product_lots, self.internal_loc_1, 0, self.lot3, ) self.check_product_amount( self.product_no_lots, self.internal_loc_2, 123, @@ -42,10 +42,10 @@ class TestMoveLocation(TestsCommon): self.product_lots, self.internal_loc_2, 1, self.lot1, ) self.check_product_amount( - self.product_lots, self.internal_loc_2, 1, self.lot1, + self.product_lots, self.internal_loc_2, 1, self.lot2, ) self.check_product_amount( - self.product_lots, self.internal_loc_2, 1, self.lot1, + self.product_lots, self.internal_loc_2, 1, self.lot3, ) def test_move_location_wizard_amount(self): diff --git a/stock_move_location/wizard/stock_move_location.py b/stock_move_location/wizard/stock_move_location.py index d4a56f37c..a83414e67 100644 --- a/stock_move_location/wizard/stock_move_location.py +++ b/stock_move_location/wizard/stock_move_location.py @@ -2,8 +2,6 @@ # Copyright 2018 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -from itertools import groupby - from odoo import api, fields, models @@ -58,22 +56,21 @@ class StockMoveLocationWizard(models.TransientModel): @api.multi def group_lines(self): - sorted_lines = sorted( - self.stock_move_location_line_ids, - key=lambda x: x.product_id, - ) - groups = groupby(sorted_lines, key=lambda x: x.product_id) - groups_dict = {} - for prod, lines in groups: - groups_dict[prod.id] = list(lines) - return groups_dict + lines_grouped = {} + for line in self.stock_move_location_line_ids: + lines_grouped.setdefault( + line.product_id.id, + self.env["wiz.stock.move.location.line"].browse(), + ) + lines_grouped[line.product_id.id] |= line + return lines_grouped @api.multi def _create_moves(self, picking): self.ensure_one() groups = self.group_lines() moves = self.env["stock.move"] - for group, lines in groups.items(): + for lines in groups.values(): move = self._create_move(picking, lines) moves |= move return moves @@ -82,14 +79,14 @@ class StockMoveLocationWizard(models.TransientModel): # locations are same for the products location_from_id = lines[0].origin_location_id.id location_to_id = lines[0].destination_location_id.id - product_id = lines[0].product_id.id + product = lines[0].product_id product_uom_id = lines[0].product_uom_id.id qty = sum([x.move_quantity for x in lines]) return { - "name": "test", + "name": product.display_name, "location_id": location_from_id, "location_dest_id": location_to_id, - "product_id": product_id, + "product_id": product.id, "product_uom": product_uom_id, "product_uom_qty": qty, "picking_id": picking.id,