Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply suggestions from code review
Browse files Browse the repository at this point in the history
grindtildeath authored Sep 11, 2019
1 parent 782e563 commit 747d936
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ class StockLocation(models.Model):
def _find_picking_type_for_routing_operation(self):
self.ensure_one()
# First select all the parent locations and the matching
# zones. In a second step, the zone matching the closest location
# picking types. In a second step, the picking type matching the closest location
# is searched in memory. This is to avoid doing an SQL query
# for each location in the tree.
tree = self.search(
18 changes: 9 additions & 9 deletions stock_picking_type_routing_operation/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ def _split_per_routing_operation(self):
location = move_line.location_id
move_lines[location] = sum(move_line.mapped('product_uom_qty'))

# We'll split the move to have one move per different zones where
# We'll split the move to have one move per different location where
# we have to take products
routing_quantities = {}
for source_location, qty in move_lines.items():
@@ -39,8 +39,8 @@ def _split_per_routing_operation(self):
routing_quantities[routing_picking_type] += qty

if len(routing_quantities) == 1:
# The whole quantity can be taken from only one zone (a
# non-zone being equal to a zone here), nothing to split.
# The whole quantity can be taken from only one location (an
# empty routing picking type being equal to one location here), nothing to split.
continue

move._do_unreserve()
@@ -49,24 +49,24 @@ def _split_per_routing_operation(self):
# not sure it's correct
routing_location = routing_picking_type.default_location_src_id
for picking_type, qty in routing_quantities.items():
# if zone is False-ish, we take in a location which is
# if picking type is empty, we don't need a new move
# not a zone
if picking_type:
# split returns the same move if the qty is the same
# if we have a picking type, split returns the same move if the qty is the same
new_move_id = move._split(qty)
new_move_per_location.setdefault(routing_location.id, [])
new_move_per_location[routing_location.id].append(
new_move_id
)

# it is important to assign the zones first
# it is important to assign the routed moves first
for location_id, new_move_ids in new_move_per_location.items():
new_moves = self.browse(new_move_ids)
new_moves.with_context(
# Prevent to call _apply_move_location_zone, will be called
# Prevent to call _apply_move_location_routing_operation, will be called
# when all lines are processed.
exclude_apply_routing_operation=True,
# Force reservation of quants in the zone they were
# Force reservation of quants in the location they were
# reserved in at the origin (so we keep the same quantities
# at the same places)
gather_in_location_id=location_id,
@@ -90,7 +90,7 @@ def _apply_move_location_routing_operation(self):
# operations while others not. Store the number of products to
# take from each location, so we'll be able to split the move
# if needed.
# At this point, we should not have lines with different zones,
# At this point, we should not have lines with different source locations,
# they have been split in _split_per_routing_operation(), so we
# can take the first one
source = move.move_line_ids[0].location_id
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
<field name="inherit_id" ref="stock.view_location_form" />
<field name="arch" type="xml">
<field name="putaway_strategy_id" position="after">
<field name="routing_operation_picking_type_id" />
<field name="routing_operation_picking_type_id" context="{'default_default_location_src_id': active_id}" />
</field>
</field>
</record>

0 comments on commit 747d936

Please sign in to comment.