Skip to content

Commit 90d87e3

Browse files
committed
[FIX] stock_move_zone_location_source: Zone should come from move lines
As Odoo does not reflect the leaf location from where the product is eventually taken from on the stock move level, take the zone location source from the move line.
1 parent fe8696f commit 90d87e3

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

stock_move_zone_location_source/models/stock_move.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def _find_source_zone_location_move(self, visited=None):
2020
# that is considered as the the source one
2121
# WARNING: The first call should be done with a single recordset
2222
all_moves = self.filtered(
23-
"location_id.zone_location_id.is_considered_as_source"
23+
"move_line_ids.location_id.zone_location_id.is_considered_as_source"
2424
)
2525
unvisited_moves = (self - visited) if visited else self
2626
for move in unvisited_moves:
@@ -30,6 +30,7 @@ def _find_source_zone_location_move(self, visited=None):
3030
@api.depends("move_orig_ids")
3131
def _compute_source_zone_location_ids(self):
3232
for move in self:
33+
source_move = move._find_source_zone_location_move()
3334
move.source_zone_location_ids = (
34-
move._find_source_zone_location_move().location_id.zone_location_id
35+
source_move.move_line_ids.location_id.zone_location_id
3536
)

stock_move_zone_location_source/tests/common.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,21 @@ def setUpClass(cls):
2222

2323
# WH (view)
2424
#
25-
# FOOD(view/zone/source) STOCK (zone/source) PHARMA(view/zone/source)
25+
# STOCK
26+
#
27+
#
28+
# FOOD(view/zone/source) PHARMA(view/zone/source)
2629
#
2730
# FOOD 1 PHARMA 1
2831

2932
# Set delivery in three steps in order to check
3033
# the good origin
3134
cls.warehouse.delivery_steps = "pick_pack_ship"
3235

36+
# Set Stock location as source too (for products that do not come from sub zones)
37+
cls.warehouse.lot_stock_id.is_zone = True
38+
cls.warehouse.lot_stock_id.is_considered_as_source = True
39+
3340
# Create several picking zones (e.g.: Pharmaceutical, Food)
3441
cls.pharma_location = cls.Location.create(
3542
{
@@ -73,9 +80,7 @@ def setUpClass(cls):
7380
"location_id": cls.food_location.id,
7481
}
7582
)
76-
# Set stock as source too
77-
cls.warehouse.lot_stock_id.is_zone = True
78-
cls.warehouse.lot_stock_id.is_considered_as_source = True
83+
7984
cls.food_type = cls.PickingType.create(
8085
{
8186
"name": "Picking Food",
@@ -128,7 +133,7 @@ def setUpClass(cls):
128133
"name": "Pharma > Pack",
129134
"location_dest_id": cls.warehouse.wh_pack_stock_loc_id.id,
130135
"procure_method": "make_to_stock",
131-
"location_src_id": cls.pharma_location.id,
136+
"location_src_id": cls.warehouse.lot_stock_id.id,
132137
"action": "pull",
133138
"route_id": cls.pharma_route.id,
134139
"picking_type_id": cls.pharma_type.id,
@@ -140,7 +145,7 @@ def setUpClass(cls):
140145
"name": "Food > Pack",
141146
"location_dest_id": cls.warehouse.wh_pack_stock_loc_id.id,
142147
"procure_method": "make_to_stock",
143-
"location_src_id": cls.food_location.id,
148+
"location_src_id": cls.warehouse.lot_stock_id.id,
144149
"action": "pull",
145150
"route_id": cls.food_route.id,
146151
"picking_type_id": cls.food_type.id,

0 commit comments

Comments
 (0)