From d3247db07685d66dd8a293b81125ff6940d4bb0a Mon Sep 17 00:00:00 2001 From: "Harry (Open ERP)" Date: Wed, 17 Mar 2010 13:49:51 +0530 Subject: [PATCH] [IMP] mrp: improve produce wizard bzr revid: hmo@tinyerp.com-20100317081951-9b1q587vlx2pnwb4 --- addons/mrp/mrp.py | 24 +++++++++++++++++++++--- addons/mrp/wizard/mrp_product_produce.py | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 05034c2..3f9058b 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -577,7 +577,23 @@ class mrp_production(osv.osv): res = False return res - def do_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): + def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): + """ + @summary: To produce final product base on production mode (consume/consume&produce). + If Production mode is consume, all stock move lines of raw materials will be done/consumed. + If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed + and stock move lines of final product will be also done/produced. + + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param production_id: the ID of mrp.production object + @param production_qty: specify qty to produce + @param production_mode: specify production mode (consume/consume&produce). + + @return: True + + """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) @@ -585,6 +601,7 @@ class mrp_production(osv.osv): final_product_todo = [] if production_mode in ['consume','consume_produce']: + # To consume remaining qty of raw materials consumed_products = {} produced_qty = 0 for consumed_product in production.move_lines2: @@ -602,9 +619,10 @@ class mrp_production(osv.osv): if rest_qty > production.product_qty: rest_qty = production.product_qty if rest_qty > 0: - stock_mov_obj.consume_moves(cr, uid, [raw_product.id], rest_qty, production.location_src_id.id, context=context) + stock_mov_obj.action_consume(cr, uid, [raw_product.id], rest_qty, production.location_src_id.id, context=context) if production_mode == 'consume_produce': + # To produce remaining qty of final product vals = {'state':'confirmed'} final_product_todo = [x.id for x in production.move_created_ids] stock_mov_obj.write(cr, uid, final_product_todo, vals) @@ -620,7 +638,7 @@ class mrp_production(osv.osv): if rest_qty <= production_qty: production_qty = rest_qty if rest_qty > 0 : - stock_mov_obj.consume_moves(cr, uid, [produce_product.id], production_qty, production.location_dest_id.id, context=context) + stock_mov_obj.action_consume(cr, uid, [produce_product.id], production_qty, production.location_dest_id.id, context=context) for raw_product in production.move_lines2: diff --git a/addons/mrp/wizard/mrp_product_produce.py b/addons/mrp/wizard/mrp_product_produce.py index 387465e..b1579f5 100644 --- a/addons/mrp/wizard/mrp_product_produce.py +++ b/addons/mrp/wizard/mrp_product_produce.py @@ -72,7 +72,7 @@ class mrp_product_produce(osv.osv_memory): move_ids = context['active_ids'] for data in self.read(cr, uid, ids): for move_id in move_ids: - prod_obj.do_produce(cr, uid, move_id, + prod_obj.action_produce(cr, uid, move_id, data['product_qty'], data['mode'], context=context) return {} -- 1.7.10.4