From 9689293daf3698a5a79fd0755d7249b314ff2379 Mon Sep 17 00:00:00 2001 From: "aag (OpenERP)" Date: Thu, 3 Feb 2011 12:41:44 +0530 Subject: [PATCH] [FIX] STOCK:Now Invoice Available Products in the Sale Order If It Has Not Available Products lp bug: https://launchpad.net/bugs/708434 fixed bzr revid: aag@tinyerp.co.in-20110203071144-0xbkqlf7h8ek9a7g --- addons/stock/stock.py | 3 +-- addons/stock/wizard/stock_partial_picking.py | 22 +++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index c942818a3d4..4fc43c54d45 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1166,8 +1166,7 @@ class stock_picking(osv.osv): for move in pick.move_lines: if move.state in ('done', 'cancel'): continue - partial_data = partial_datas.get('move%s'%(move.id), False) - assert partial_data, _('Missing partial picking data for move #%s') % (move.id) + partial_data = partial_datas.get('move%s'%(move.id), {}) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py index 9f644c981a8..cc858f0f726 100644 --- a/addons/stock/wizard/stock_partial_picking.py +++ b/addons/stock/wizard/stock_partial_picking.py @@ -67,8 +67,9 @@ class stock_partial_picking(osv.osv_memory): for m in pick.move_lines: if m.state in ('done', 'cancel'): continue - result.append(self.__create_partial_picking_memory(m, pick_type)) - + move_memory = self.__create_partial_picking_memory(m, pick_type) + if move_memory: + result.append(move_memory) if 'product_moves_in' in fields: res.update({'product_moves_in': result}) if 'product_moves_out' in fields: @@ -124,12 +125,27 @@ class stock_partial_picking(osv.osv_memory): 'prodlot_id' : picking.prodlot_id.id, 'move_id' : picking.id, } - + if pick_type == 'in': move_memory.update({ 'cost' : picking.product_id.standard_price, 'currency' : picking.product_id.company_id and picking.product_id.company_id.currency_id and picking.product_id.company_id.currency_id.id or False, }) + + if pick_type == 'out': + type = picking.picking_id.move_type + qty_avl = picking.product_id.qty_available + if type == 'direct' : + if qty_avl <= 0.0 and picking.state != 'assigned': + move_memory = {} + if picking.product_qty > qty_avl and qty_avl > 0.0: + move_memory.update({ + 'quantity' : qty_avl, + }) + if picking.state == 'assigned': + move_memory.update({ + 'quantity' : picking.product_qty, + }) return move_memory def do_partial(self, cr, uid, ids, context=None):