1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6
# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
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
##############################################################################
23
from osv import fields, osv
25
class wizard_replenish(osv.osv_memory):
27
def _get_product(self, cr, uid, context=None):
30
if 'active_id' in context:
31
replenish = self.pool.get('multilocation.replenish').browse(cr, uid, context['active_id'], context=context)
32
return replenish.product_name.id
34
def ok_action(self, cr, uid, ids, context=None):
38
data = self.pool.get('wizard.replenish').browse(cr, uid, ids[0])
39
if 'active_id' in context:
40
replenish = self.pool.get('multilocation.replenish').browse(cr, uid, context['active_id'])
41
if data.qty > 0 and data.qty <= replenish.amt_to_move:
43
'product_id': replenish.product_name.id,
44
'location_id': replenish.replenish_loc.id,
45
'location_dest_id': replenish.primary_loc.id,
46
'product_qty': data.qty,
47
'product_uom': replenish.product_name.uom_id.id,
50
picking_id = self.pool.get('stock.picking').create(cr, uid, {
51
'origin': replenish.replenish_move,
54
'move_type': 'direct',
56
vals['picking_id'] = picking_id
57
vals['name'] = replenish.replenish_move
58
move_id = self.pool.get('stock.move').create(cr, uid, vals, context=context)
59
replenish.write({'amt_moved': data.qty, 'state': 'done'}, context=context)
60
if data.remove_sec_loc:
61
if replenish.amt_left <= 0:
62
multi_loc_obj = self.pool.get('stock.multi.location')
63
stock_loc_id = multi_loc_obj.search(cr, uid, [('location_name', '=', replenish.replenish_loc.id)], context=context)
64
multi_loc_obj.unlink(cr, uid, stock_loc_id, context=context)
67
def _get_left_qty(self, cr, uid, context=None):
70
if 'active_id' in context:
71
replenish = self.pool.get('multilocation.replenish').browse(cr, uid, context['active_id'], context=context)
72
if replenish.amt_left <=0:
77
def _get_qty(self, cr, uid, context=None):
80
if 'active_id' in context:
81
replenish = self.pool.get('multilocation.replenish').browse(cr, uid, context['active_id'], context=context)
82
return replenish.amt_to_move
84
_name = "wizard.replenish"
86
'product_id': fields.many2one('product.product', 'Product'),
87
'remove_sec_loc': fields.boolean('Remove The Secondory Location'),
88
'qty': fields.integer('Amount to Replenish'),
89
'real_lt_qty': fields.boolean('Real stock lt QTY'),
92
'product_id': _get_product,
94
'real_lt_qty': _get_left_qty,
95
'remove_sec_loc': True
100
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
b'\\ No newline at end of file'