From cfa26c6bbe1621d3af0744b752fd16cc040cf16c Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 4 Feb 2009 22:04:04 +0100 Subject: [PATCH] bugfox bzr revid: fp@tinyerp.com-20090204210404-dlrlur1l0wg6rm67 --- addons/stock/wizard/inventory_merge_zero.py | 39 ++++++++------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/addons/stock/wizard/inventory_merge_zero.py b/addons/stock/wizard/inventory_merge_zero.py index a9f80be2b17..1b0527ad142 100644 --- a/addons/stock/wizard/inventory_merge_zero.py +++ b/addons/stock/wizard/inventory_merge_zero.py @@ -38,6 +38,7 @@ _inventory_fields = { 'string':'Location', 'type':'many2one', 'relation':'stock.location', + 'required':True } } @@ -51,34 +52,22 @@ def do_merge(self, cr, uid, data, context): raise wizard.except_wizard("Warning", "Please select one and only one inventory !") - cr.execute('select distinct location_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],)) - loc_ids = map(lambda x: x[0], cr.fetchall()) - if data['form']['location_id']: - loc_ids.append(data['form']['location_id']) - locs = ','.join(map(lambda x: str(x), loc_ids)) + loc = str(data['form']['location_id']) cr.execute('select distinct location_id,product_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],)) inv = cr.fetchall() - if not locs: - raise wizard.except_wizard("Warning", - "Please select at least one inventory location !") -# if not inv: -# raise wizard.except_wizard("Warning", -# "Please select at least one inventory location !") - else: - cr.execute('select distinct product_id from stock_move where (location_dest_id in ('+locs+')) or (location_id in ('+locs+'))') - stock = cr.fetchall() - for s in stock: - for loc in loc_ids: - if (loc,s[0]) not in inv: - p = prod_obj.browse(cr, uid, s[0]) - invent_line_obj.create(cr, uid, { - 'inventory_id': data['ids'][0], - 'location_id': loc, - 'product_id': s[0], - 'product_uom': p.uom_id.id, - 'product_qty': 0.0, - }) + cr.execute('select distinct product_id from stock_move where (location_dest_id='+loc+') or (location_id='+loc+')') + stock = cr.fetchall() + for s in stock: + if (loc,s[0]) not in inv: + p = prod_obj.browse(cr, uid, s[0]) + invent_line_obj.create(cr, uid, { + 'inventory_id': data['ids'][0], + 'location_id': loc, + 'product_id': s[0], + 'product_uom': p.uom_id.id, + 'product_qty': 0.0, + }) return {}