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 @@
+
diff --git a/addons/stock/wizard/stock_inventory_set_stock_zero.py b/addons/stock/wizard/stock_inventory_set_stock_zero.py
deleted file mode 100644
index 4cbba93bdb6..00000000000
--- a/addons/stock/wizard/stock_inventory_set_stock_zero.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-from osv import fields, osv
-from tools.translate import _
-
-class inventory_set_stock_zero(osv.osv_memory):
- _name = "stock.inventory.set.stock.zero"
- _description = "Set Stock to 0"
-
- _columns = {
- 'location_id': fields.many2one('stock.location', 'Location', required=True),
- }
-
- def do_merge(self, cr, uid, ids, context):
- """ To set stock to Zero
- @param self: The object pointer.
- @param cr: A database cursor
- @param uid: ID of the user currently logged in
- @param ids: the ID or list of IDs if we want more than one
- @param context: A standard dictionary
- @return:
- """
- invent_obj = self.pool.get('stock.inventory')
- invent_line_obj = self.pool.get('stock.inventory.line')
- prod_obj = self.pool.get('product.product')
-
- if len(context['active_ids']) <> 1:
- raise osv.except_osv(_('Warning'),
- _('Please select one and only one inventory !'))
- for id in ids:
- datas = self.read(cr, uid, id)
- loc = str(datas['location_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,
- })
- return {}
-
-inventory_set_stock_zero()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml b/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml
deleted file mode 100644
index 0ee84d2045d..00000000000
--- a/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
- Set Stock to Zero
- stock.inventory.set.stock.zero
- form
-
-
-
-
-
-
-
-
-