Skip to content

Commit

Permalink
Allow to bypass the routing operation for a move
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-dacosta authored and guewen committed Dec 13, 2019
1 parent 5df54bc commit 087814d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions stock_routing_operation/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 087814d

Please sign in to comment.