From 087814dbc6fedd9982f18725c0227d9b034fb42f Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Fri, 13 Dec 2019 15:32:49 +0100 Subject: [PATCH] Allow to bypass the routing operation for a move --- stock_routing_operation/models/stock_move.py | 29 +++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/stock_routing_operation/models/stock_move.py b/stock_routing_operation/models/stock_move.py index fa0df884b6b0..a32e9b882df0 100644 --- a/stock_routing_operation/models/stock_move.py +++ b/stock_routing_operation/models/stock_move.py @@ -1,6 +1,7 @@ # Copyright 2019 Camptocamp (https://www.camptocamp.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) from itertools import chain + from odoo import models @@ -21,6 +22,14 @@ def _apply_dest_move_routing_operation(self): dest_moves = self._split_per_dest_routing_operation() dest_moves._apply_move_location_dest_routing_operation() + def _bypass_routing_operation_application(self, routing_type): + """ Override this method if you need to by pass the routing operation + logic for moves related characteristic. + """ + if routing_type not in ("src", "dest"): + raise ValueError("routing_type must be one of ('src', 'dest')") + return False + def _split_per_src_routing_operation(self): """Split moves per source routing operations @@ -35,7 +44,10 @@ def _split_per_src_routing_operation(self): move_to_assign_ids = set() new_move_per_location = {} for move in self: - if move.state not in ("assigned", "partially_available"): + if move.state not in ( + "assigned", + "partially_available", + ) or move._bypass_routing_operation_application("src"): continue # Group move lines per source location, some may need an additional @@ -110,7 +122,10 @@ def _apply_move_location_src_routing_operation(self): after it. """ for move in self: - if move.state not in ("assigned", "partially_available"): + if move.state not in ( + "assigned", + "partially_available", + ) or move._bypass_routing_operation_application("src"): continue # Group move lines per source location, some may need an additional @@ -204,7 +219,10 @@ def _split_per_dest_routing_operation(self): """ new_moves = self.browse() for move in self: - if move.state not in ("assigned", "partially_available"): + if move.state not in ( + "assigned", + "partially_available", + ) or move._bypass_routing_operation_application("dest"): continue # Group move lines per destination location, some may need an @@ -260,7 +278,10 @@ def _apply_move_location_dest_routing_operation(self): after it. """ for move in self: - if move.state not in ("assigned", "partially_available"): + if move.state not in ( + "assigned", + "partially_available", + ) or move._bypass_routing_operation_application("dest"): continue # Group move lines per source location, some may need an additional