diff --git a/stock_putaway_by_route/models/stock_move.py b/stock_putaway_by_route/models/stock_move.py index 3ab780637e0e..83bd9f4c31eb 100644 --- a/stock_putaway_by_route/models/stock_move.py +++ b/stock_putaway_by_route/models/stock_move.py @@ -1,4 +1,5 @@ # Copyright 2020 Camptocamp +# Copyright 2024 Michael Tietz (MT Software) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import models @@ -16,11 +17,18 @@ def _generate_serial_move_line_commands(self, lot_names, origin_move_line=None): lot_names, origin_move_line=origin_move_line ) - def _prepare_move_line_vals(self, quantity=None, reserved_quant=None): + def _get_putaway_routes(self): + routes = self.env["stock.location"] if self.rule_id.route_id: - self = self.with_context(_putaway_route_id=self.rule_id.route_id) + routes = self.rule_id.route_id elif self.product_id.route_ids: - self = self.with_context(_putaway_route_id=self.product_id.route_ids) + routes = self.product_id.route_ids + return routes + + def _prepare_move_line_vals(self, quantity=None, reserved_quant=None): + putaway_routes = self._get_putaway_routes() + if putaway_routes: + self = self.with_context(_putaway_route_id=putaway_routes) return super()._prepare_move_line_vals( quantity=quantity, reserved_quant=reserved_quant ) diff --git a/stock_putaway_by_route/readme/CONTRIBUTORS.rst b/stock_putaway_by_route/readme/CONTRIBUTORS.rst index 36ac008dbbcc..2725c5cb79f6 100644 --- a/stock_putaway_by_route/readme/CONTRIBUTORS.rst +++ b/stock_putaway_by_route/readme/CONTRIBUTORS.rst @@ -3,3 +3,4 @@ Trobz * Dung Tran +* Michael Tietz (MT Software)