[FIX] purchase: picking list

When a product is returned after receiving, the return picking doesn't
appear in the corresponding PO.

opw-686895
This commit is contained in:
Nicolas Martinelli
2016-09-02 09:12:37 +02:00
parent 35104ee360
commit d88aa539d4
+5 -2
View File
@@ -77,12 +77,15 @@ class PurchaseOrder(models.Model):
types = type_obj.search([('code', '=', 'incoming'), ('warehouse_id', '=', False)])
return types[:1]
@api.depends('order_line.move_ids.picking_id')
@api.depends('order_line.move_ids')
def _compute_picking(self):
for order in self:
pickings = self.env['stock.picking']
for line in order.order_line:
moves = line.move_ids.filtered(lambda r: r.state != 'cancel')
# We keep a limited scope on purpose. Ideally, we should also use move_orig_ids and
# do some recursive search, but that could be prohibitive if not done correctly.
moves = line.move_ids | line.move_ids.mapped('returned_move_ids')
moves = moves.filtered(lambda r: r.state != 'cancel')
pickings |= moves.mapped('picking_id')
order.picking_ids = pickings
order.picking_count = len(pickings)