[FIX] mrp: cancel raw materials procurements

To reproduce:
- Create a product A with the routes Manufacturing & Make to Order
- Create a product B with the routes Make to Order & a custom one "Move
  from Shelf 1" (see screenshot for the configuration detail)
- Create a BoM for product A which contains the component product B
- Sell product A in a SO and confirm it
- It creates a delivery order for product A, a manufacturing order for
  Product A & B and an internal transfer for product B
- The move for product B from WH/Stock/Shelf 1 to WH/Stock is indeed
  linked to the move for product B from WH/Stock to Virtual Location/Production
- Cancel the sales order
- All stock moves are cancelled, except the one related to the internal
  transfer (WH/Stock/Shelf 1 to WH/Stock)

When the manufacturing order is canceled, raw material as well as
finished moves are canceled. All procurements with finished moves as
"Destination Move" are canceled as well. However, in this use case, a
procurement has been created for a raw material.

The solution is to cancel procurements for raw materials as well, so it
cancels the internal transfer.

opw-706100
This commit is contained in:
Nicolas Martinelli
2017-02-13 09:01:10 +01:00
parent 2a08cbb8c6
commit b5b4979dd1
+3 -3
View File
@@ -467,10 +467,10 @@ class MrpProduction(models.Model):
production.workorder_ids.filtered(lambda x: x.state != 'cancel').action_cancel()
finish_moves = production.move_finished_ids.filtered(lambda x: x.state not in ('done', 'cancel'))
production.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel')).action_cancel()
finish_moves.action_cancel()
raw_moves = production.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel'))
(finish_moves | raw_moves).action_cancel()
procurements = ProcurementOrder.search([('move_dest_id', 'in', finish_moves.ids)])
procurements = ProcurementOrder.search([('move_dest_id', 'in', (finish_moves | raw_moves).ids)])
if procurements:
procurements.cancel()