Skip to content

Commit 0759d32

Browse files
committed
Merge PR #556 into 18.0
Signed-off-by LoisRForgeFlow
2 parents bf68c91 + 2423da2 commit 0759d32

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

ddmrp/models/stock_move.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,31 @@ def _find_buffers_to_update_nfp(self):
6161
out_buffers = in_buffers = self.env["stock.buffer"]
6262
for move in self:
6363
out_buffers |= move.mapped("product_id.buffer_ids").filtered(
64-
lambda buffer: (
65-
move.location_id.is_sublocation_of(buffer.location_id) # noqa: B023
66-
and not move.location_dest_id.is_sublocation_of(buffer.location_id) # noqa: B023
64+
lambda buffer, move=move: (
65+
move.location_id.is_sublocation_of(buffer.location_id)
66+
and (
67+
not move.location_dest_id.is_sublocation_of(buffer.location_id)
68+
or (
69+
move.location_final_id
70+
and not move.location_final_id.is_sublocation_of(
71+
buffer.location_id
72+
)
73+
)
74+
)
6775
)
6876
)
6977
in_buffers |= move.mapped("product_id.buffer_ids").filtered(
70-
lambda buffer: (
71-
not move.location_id.is_sublocation_of(buffer.location_id) # noqa: B023
72-
and move.location_dest_id.is_sublocation_of(buffer.location_id) # noqa: B023
78+
lambda buffer, move=move: (
79+
not move.location_id.is_sublocation_of(buffer.location_id)
80+
and (
81+
move.location_dest_id.is_sublocation_of(buffer.location_id)
82+
or (
83+
move.location_final_id
84+
and move.location_final_id.is_sublocation_of(
85+
buffer.location_id
86+
)
87+
)
88+
)
7389
)
7490
)
7591
return out_buffers, in_buffers

ddmrp/tests/test_ddmrp.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,12 @@ def test_47_incoming_quantity_from_final_location(self):
13441344
self.assertEqual(move.location_dest_id, self.warehouse.wh_input_stock_loc_id)
13451345
self.assertEqual(move.location_final_id, self.warehouse.lot_stock_id)
13461346
self.assertEqual(move.product_qty, 225)
1347+
_ob, in_buffers = move._find_buffers_to_update_nfp()
1348+
self.assertIn(
1349+
self.buffer_purchase,
1350+
in_buffers,
1351+
"Buffer won't be found for auto-NFP update",
1352+
)
13471353
self.buffer_purchase.cron_actions()
13481354
self.assertEqual(self.buffer_purchase.incoming_dlt_qty, 225.0)
13491355
# Validating should generate the next picking.
@@ -1411,6 +1417,12 @@ def test_48_outgoing_quantity_with_final_location(self):
14111417
# Validating should generate the next picking.
14121418
self.assertFalse(move.move_dest_ids)
14131419
picking_1 = move.picking_id
1420+
out_buffers, _ib = move._find_buffers_to_update_nfp()
1421+
self.assertIn(
1422+
self.buffer_purchase,
1423+
out_buffers,
1424+
"Buffer won't be found for auto-NFP update",
1425+
)
14141426
self._do_picking(picking_1, datetime.today())
14151427
self.assertEqual(len(move.move_dest_ids), 1)
14161428
picking_2 = move.move_dest_ids.picking_id

0 commit comments

Comments
 (0)