=== modified file 'stock/stock.py' --- stock/stock.py 2013-09-20 11:24:37 +0000 +++ stock/stock.py 2013-10-01 09:55:08 +0000 @@ -1239,6 +1239,7 @@ for pick in self.browse(cr, uid, ids, context=context): new_picking = None complete, too_many, too_few = [], [], [] + temp_qty = 0.0 move_product_qty, prodlot_ids, product_avail, partial_qty, product_uoms = {}, {}, {}, {}, {} for move in pick.move_lines: if move.state in ('done', 'cancel'): @@ -1278,6 +1279,14 @@ new_price = uom_obj._compute_price(cr, uid, product_uom, new_price, product.uom_id.id) if product.qty_available <= 0: + move_ids = move_obj.search(cr, uid, [('product_id','=',product.id),('picking_id','=',pick.id)]) + if (move_ids and len(move_ids) >=2) and complete: + amount_unit = product.price_get('standard_price', context=context)[product.id] + new_std_price = ((amount_unit * temp_qty)\ + + (new_price * qty))/(temp_qty + qty) + temp_qty += move.product_qty + else: + new_std_price = new_price new_std_price = new_price else: # Get the standard price