Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions purchase_all_shipments/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import purchase_order
from . import stock_move
7 changes: 3 additions & 4 deletions purchase_all_shipments/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ def _compute_all_picking_count(self):

def _compute_all_pickings(self):
for rec in self:
groups = rec.mapped("picking_ids.group_id")
all_picking_ids = self.env["stock.picking"].search(
[("group_id", "in", groups.ids)]
moves = rec.order_line.move_ids
rec.all_picking_ids = (
rec.picking_ids | moves._get_reception_chain_moves().picking_id
)
rec.all_picking_ids = all_picking_ids

def action_view_all_pickings(self):
return self._get_action_view_all_pickings(self.all_picking_ids)
Expand Down
18 changes: 18 additions & 0 deletions purchase_all_shipments/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import models


class StockMove(models.Model):
_inherit = "stock.move"

def _get_reception_chain_moves(self):
"""Recursively get the destination moves that continue the reception.

Moves pushed by the reception route are part of it, while moves pulled
by the demand of another document are not.
"""
res = self.move_dest_ids.filtered(lambda m: m.rule_id.action == "push")
if res:
res |= res._get_reception_chain_moves()
return res
15 changes: 15 additions & 0 deletions purchase_all_shipments/tests/test_three_step_reception.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ def test_three_steps_generate_three_pickings(self):
self.po._compute_all_picking_count()
self.assertEqual(3, self.po.all_picking_count)

def test_picking_of_other_document_excluded(self):
self.po.button_confirm()
other_picking = self.env["stock.picking"].create(
{
"picking_type_id": self.wh.out_type_id.id,
"location_id": self.wh.lot_stock_id.id,
"location_dest_id": self.env.ref("stock.stock_location_customers").id,
"group_id": self.po.group_id.id,
}
)
self.po._compute_all_pickings()
self.po._compute_all_picking_count()
self.assertNotIn(other_picking, self.po.all_picking_ids)
self.assertEqual(1, self.po.all_picking_count)

def test_action_view_all_pickings_one_step(self):
self.po.button_confirm()
action_data = self.po.action_view_all_pickings()
Expand Down
Loading