odoo/odoo — pull request #1296 by rgo-odoo (2014-07-21 09:18:08+00:00)
Title: 7.0 opw 609450 rgo

This branch fixes two issues of mrp from two OPWs,

Issue 1: Fixed the broken upstream traceability(609450)(For the information, statement at line# 811 fixes this issue if someone wants to test each case individually).

Steps to reproduce the issue:
- Create an MO for product "[C-Case] Computer Case" and process(produce) it with option "Consume & Produce"
- Split the Produced(finished) product in serial number
- Go to the "Warehouse/Traceability/Serial Number" menu and open the step-2 record in form view and click on the "Upstream Traceability" button

Expected result: Expanding the produced product shows all of it's components.

Current result: It is not showing all of it's components but only one.

This is because, when the MO is being produced through method 'action_produce(...)' of 'mrp.production' model, the browse_record for the current model still hold the old value(that is, it has final product in the "Products to produce"(move_created_ids) list instead of "Produced Products"(move_created_ids2)) when it comes to write the 'move_history_ids' and it result in this bug.

Issue 2: MO does not go into the done state if followed the below steps(610515),

- Create parts:
A & B as "to order"
C as "to stock". Add some stock of this part.
- Create BoM structure as below,
BoM for A(Normal BoM):
Component: C
BoM for B(Phantom):
Component: C
Parent BoM: BoM of A
- Create an MO for A.
- We'd expect an MO to be created with 2 child lines - C directly and C as a phantom child of B, which is working fine.
- Start production, produce the total MO quantity.

Expected Result: We expect both child/component lines to be consumed and the MO closed (in "done" state).

Current Result: This does not happen, the system only consumes the first occurrence of C, it leaves the second occurrence as "to consume" and does not close the MO.

This is because, in such case as this one where the same component used twice in the MO, we need to refresh the "mrp.production" browse_record to be sure that the correct product consumed.

In short, we need to refresh the production browse_record after each call to action_consume() to keep the browse_record in up-to-date state.

Kindly review the fix.