From 1239d4c8cdf199d4226e8c61bf94fec9893fca17 Mon Sep 17 00:00:00 2001 From: "sbh (Open ERP)" Date: Thu, 9 Sep 2010 11:45:10 +0530 Subject: [PATCH] [ADD] stock: Improve the tooltips of fill_inventory wizard and merge set_stock_zero [REM] Remove the set_stock_zero wizard bzr revid: sbh@tinyerp.com-20100909061510-3rdpvo4m48qxehnv --- addons/stock/__openerp__.py | 1 - addons/stock/wizard/__init__.py | 1 - addons/stock/wizard/stock_fill_inventory.py | 24 +++++- .../wizard/stock_fill_inventory_view.xml | 1 + .../wizard/stock_inventory_set_stock_zero.py | 74 ------------------- .../stock_inventory_set_stock_zero_view.xml | 31 -------- 6 files changed, 23 insertions(+), 109 deletions(-) delete mode 100644 addons/stock/wizard/stock_inventory_set_stock_zero.py delete mode 100644 addons/stock/wizard/stock_inventory_set_stock_zero_view.xml diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index e33e347d612..07a9a73f10f 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -49,7 +49,6 @@ Thanks to the double entry management, the inventory controlling is powerful and "wizard/stock_move_view.xml", "wizard/stock_partial_picking_view.xml", "wizard/stock_partial_move_view.xml", - "wizard/stock_inventory_set_stock_zero_view.xml", "wizard/stock_fill_inventory_view.xml", "wizard/stock_invoice_onshipping_view.xml", "wizard/stock_inventory_merge_view.xml", diff --git a/addons/stock/wizard/__init__.py b/addons/stock/wizard/__init__.py index 7a13dc26fd5..f6021e0fbe2 100644 --- a/addons/stock/wizard/__init__.py +++ b/addons/stock/wizard/__init__.py @@ -27,7 +27,6 @@ import stock_partial_move import stock_replacement import stock_ups import stock_inventory_merge -import stock_inventory_set_stock_zero import stock_fill_inventory import stock_inventory_line_split import stock_invoice_onshipping diff --git a/addons/stock/wizard/stock_fill_inventory.py b/addons/stock/wizard/stock_fill_inventory.py index d79d9d61fe0..e9b3fb2e02c 100644 --- a/addons/stock/wizard/stock_fill_inventory.py +++ b/addons/stock/wizard/stock_fill_inventory.py @@ -27,7 +27,8 @@ class stock_fill_inventory(osv.osv_memory): _description = "Import Inventory" _columns = { 'location_id': fields.many2one('stock.location', 'Location', required=True), - 'recursive': fields.boolean("Include all children for the location"), + 'recursive': fields.boolean("Include children",help="If checked, products contained in child locations of selected location will be included as well."), + 'set_stock_zero': fields.boolean("Set to zero",help="If checked, all product quantities will be set to zero to help ensure a real physical inventory is done and when set all inventory lines that are added to the inventory should have zero as quantity"), } def fill_inventory(self, cr, uid, ids, context): @@ -52,12 +53,31 @@ class stock_fill_inventory(osv.osv_memory): for location in location_ids : res = location_obj._product_get(cr, uid, location) res_location[location] = res + if fill_inventory.set_stock_zero: + loc = fill_inventory.location_id.id + cr.execute('select distinct location_id,product_id \ + from stock_inventory_line \ + where inventory_id=%s', (context['active_id'],)) + inv = cr.fetchall() + cr.execute('select distinct product_id from stock_move where \ + location_dest_id=%s or location_id=%s', (loc, 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': context['active_id'], + 'location_id': loc, + 'product_id': s[0], + 'product_uom': p.uom_id.id, + 'product_qty': 0.0, + }) else: context.update({'compute_child': False}) res = location_obj._product_get(cr, uid, fill_inventory.location_id.id, context=context) res_location[fill_inventory.location_id.id] = res - + product_ids = [] for location in res_location.keys(): res = res_location[location] diff --git a/addons/stock/wizard/stock_fill_inventory_view.xml b/addons/stock/wizard/stock_fill_inventory_view.xml index 04e66e525e5..40cf34af26b 100644 --- a/addons/stock/wizard/stock_fill_inventory_view.xml +++ b/addons/stock/wizard/stock_fill_inventory_view.xml @@ -12,6 +12,7 @@ +