From c267541a96d1e5e78cf3a33a2f6684ab544c92b3 Mon Sep 17 00:00:00 2001 From: ThiagoMForgeFlow Date: Thu, 2 Jan 2025 12:27:07 +0100 Subject: [PATCH] [MIG] stock_move_forced_lot: Migration to 17.0 --- stock_move_forced_lot/__manifest__.py | 2 +- stock_move_forced_lot/models/stock_move.py | 6 +++--- stock_move_forced_lot/models/stock_rule.py | 4 ++-- .../tests/test_stock_move_forced_lot.py | 12 +++++------- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/stock_move_forced_lot/__manifest__.py b/stock_move_forced_lot/__manifest__.py index 853914204d1f..2cda64604bca 100644 --- a/stock_move_forced_lot/__manifest__.py +++ b/stock_move_forced_lot/__manifest__.py @@ -7,7 +7,7 @@ This module allows you to set a lot_id in a procurement to force the stock move generated to only reserve the selected lot. """, - "version": "14.0.1.0.0", + "version": "17.0.1.0.0", "license": "LGPL-3", "author": "ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-workflow", diff --git a/stock_move_forced_lot/models/stock_move.py b/stock_move_forced_lot/models/stock_move.py index 0ce45711118d..c9f82ab951db 100644 --- a/stock_move_forced_lot/models/stock_move.py +++ b/stock_move_forced_lot/models/stock_move.py @@ -7,7 +7,7 @@ class StockMove(models.Model): _inherit = "stock.move" - forced_lot_id = fields.Many2one("stock.production.lot") + forced_lot_id = fields.Many2one("stock.lot") def _get_available_quantity( self, @@ -32,8 +32,8 @@ def _get_available_quantity( def _update_reserved_quantity( self, need, - available_quantity, location_id, + quant_ids=None, lot_id=None, package_id=None, owner_id=None, @@ -43,8 +43,8 @@ def _update_reserved_quantity( lot_id = self.forced_lot_id return super()._update_reserved_quantity( need, - available_quantity, location_id, + quant_ids=quant_ids, lot_id=lot_id, package_id=package_id, owner_id=owner_id, diff --git a/stock_move_forced_lot/models/stock_rule.py b/stock_move_forced_lot/models/stock_rule.py index da12f363b317..8a09b5b53153 100644 --- a/stock_move_forced_lot/models/stock_rule.py +++ b/stock_move_forced_lot/models/stock_rule.py @@ -12,7 +12,7 @@ def _get_stock_move_values( product_id, product_qty, product_uom, - location_id, + location_dest_id, name, origin, company_id, @@ -22,7 +22,7 @@ def _get_stock_move_values( product_id, product_qty, product_uom, - location_id, + location_dest_id, name, origin, company_id, diff --git a/stock_move_forced_lot/tests/test_stock_move_forced_lot.py b/stock_move_forced_lot/tests/test_stock_move_forced_lot.py index 08bd930be5d4..a6d427bf6008 100644 --- a/stock_move_forced_lot/tests/test_stock_move_forced_lot.py +++ b/stock_move_forced_lot/tests/test_stock_move_forced_lot.py @@ -1,10 +1,10 @@ # Copyright 2022 ForgeFlow S.L. # License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) -from odoo.tests import SavepointCase +from odoo.tests.common import TransactionCase -class TestStockMoveForcedLot(SavepointCase): +class TestStockMoveForcedLot(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -15,9 +15,7 @@ def setUpClass(cls): cls.location2 = cls.env.ref("stock.stock_location_components") cls.picking_type = cls.env.ref("stock.picking_type_internal") cls.partner = cls.env["res.partner"].create({"name": "Partner"}) - route_auto = cls.env["stock.location.route"].create( - {"name": "Auto Create Group"} - ) + route_auto = cls.env["stock.route"].create({"name": "Auto Create Group"}) cls.rule_1 = cls.env["stock.rule"].create( { "name": "rule with autocreate", @@ -25,7 +23,7 @@ def setUpClass(cls): "action": "pull_push", "warehouse_id": cls.warehouse.id, "picking_type_id": cls.picking_type.id, - "location_id": cls.location1.id, + "location_dest_id": cls.location1.id, "location_src_id": cls.location2.id, "partner_address_id": cls.partner.id, } @@ -44,7 +42,7 @@ def test_01_create_procurement_with_fixed_lot(self): serials = [] for i in range(nb_product_todo): serials.append( - self.env["stock.production.lot"].create( + self.env["stock.lot"].create( { "name": f"lot_consumed_{i}", "product_id": self.product.id,