[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
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<newline/>
|
||||
<field name="recursive"/>
|
||||
<newline/>
|
||||
<field name="set_stock_zero"/>
|
||||
<separator string="" colspan="4" />
|
||||
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||
<button name="fill_inventory" string="Fill Inventory" type="object" icon="gtk-ok"/>
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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:
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_inventory_set_stock_zero" model="ir.ui.view">
|
||||
<field name="name">Set Stock to Zero</field>
|
||||
<field name="model">stock.inventory.set.stock.zero</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Set Stock to Zero">
|
||||
<separator string="Set Stocks to Zero" colspan="4" />
|
||||
<field name="location_id"/>
|
||||
<newline/>
|
||||
<label colspan="4" string="Do you want to set stocks to zero ?"/>
|
||||
<separator string="" colspan="4" />
|
||||
<button special="cancel" icon='gtk-cancel' string="Cancel" />
|
||||
<button name="do_merge" string="Set Stock to Zero" type="object" icon="gtk-ok"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window name="Set Stock to Zero"
|
||||
res_model="stock.inventory.set.stock.zero"
|
||||
src_model="stock.inventory"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
id="action_view_inventory_set_stock_zero"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user