From bc23c92c3ed07283bbd40f88ce73024572922a72 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 29 Apr 2016 15:48:55 +0200 Subject: [PATCH] [FIX] mrp: avoid empty cost of produced product If the production flow is in two steps: 1. consume raw material 2. produce manufactured product The total_consume_moves was empty (so computed cost was 0) Include the moves that were already consumed since the last production. This will offer a correct estimation of cost of production in real time for companies producing in several steps. opw-675994 --- addons/mrp/mrp.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index b94428f91fe..e972a0bfdcf 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1011,6 +1011,11 @@ class mrp_production(osv.osv): total_consume_moves.append(extra_move_id) if production_mode == 'consume_produce': + # add production lines that have already been consumed since the last 'consume & produce' + last_production_date = production.move_created_ids2 and max(production.move_created_ids2.mapped('date')) or False + already_consumed_lines = production.move_lines2.filtered(lambda l: l.date > last_production_date) + total_consume_moves += already_consumed_lines.ids + price_unit = 0 for produce_product in production.move_created_ids: is_main_product = (produce_product.product_id.id == production.product_id.id) and production.product_id.cost_method=='real'