1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
26
from tools.translate import _
29
_form = """<?xml version="1.0"?>
30
<form string="Set Stock to Zero">
31
<separator colspan="4" string="Set Stocks to Zero" />
32
<field name="location_id"/>
34
<label colspan="4" string="Do you want to set stocks to zero ?"/>
41
'relation':'stock.location',
47
def do_merge(self, cr, uid, data, context):
48
invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory')
49
invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line')
50
prod_obj = pooler.get_pool(cr.dbname).get('product.product')
52
if len(data['ids']) <> 1:
53
raise wizard.except_wizard(_('Warning'),
54
_('Please select one and only one inventory !'))
56
loc = str(data['form']['location_id'])
58
cr.execute('select distinct location_id,product_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],))
60
cr.execute('select distinct product_id from stock_move where (location_dest_id='+loc+') or (location_id='+loc+')')
63
if (loc,s[0]) not in inv:
64
p = prod_obj.browse(cr, uid, s[0])
65
invent_line_obj.create(cr, uid, {
66
'inventory_id': data['ids'][0],
69
'product_uom': p.uom_id.id,
75
class merge_inventory(wizard.interface):
79
'result' : {'type' : 'form',
81
'fields' : _inventory_fields,
82
'state' : [('end', 'Cancel'),
83
('merge', 'Set to Zero') ]}
87
'result' : {'type' : 'action',
92
merge_inventory("inventory.merge.stock.zero")
94
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: