~serpent-consulting-services/openerp-usa/fix-shipping_api_ups_cc

« back to all changes in this revision

Viewing changes to stock_multilocation_picking/wizard/replenish.py

  • Committer: npgllc
  • Date: 2012-08-02 17:13:27 UTC
  • Revision ID: npgllc-20120802171327-2xgyyjjb5d1kx26y
Removed all the 6.0 compatible modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#
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>)
7
 
#
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.
12
 
#
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.
17
 
#
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/>
20
 
#
21
 
##############################################################################
22
 
 
23
 
from osv import fields, osv
24
 
 
25
 
class wizard_replenish(osv.osv_memory):
26
 
 
27
 
    def _get_product(self, cr, uid, context=None):
28
 
        if context is None:
29
 
            context = {}
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
33
 
 
34
 
    def ok_action(self, cr, uid, ids, context=None):
35
 
        if context is None:
36
 
            context = {}
37
 
        vals = {}
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:
42
 
                vals.update({
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,
48
 
                    'state': 'done'
49
 
                    })
50
 
                picking_id = self.pool.get('stock.picking').create(cr, uid, {
51
 
                    'origin': replenish.replenish_move,
52
 
                    'type': 'internal',
53
 
                    'state': 'done',
54
 
                    'move_type': 'direct',
55
 
                    }, context=context)
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)
65
 
        return {}
66
 
 
67
 
    def _get_left_qty(self, cr, uid, context=None):
68
 
        if context is None:
69
 
            context = {}
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:
73
 
                return True
74
 
            else:
75
 
               return False
76
 
 
77
 
    def _get_qty(self, cr, uid, context=None):
78
 
        if context is None:
79
 
            context = {}
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
83
 
 
84
 
    _name = "wizard.replenish"
85
 
    _columns = {
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'),
90
 
        }
91
 
    _defaults = {
92
 
        'product_id': _get_product,
93
 
        'qty': _get_qty,
94
 
        'real_lt_qty': _get_left_qty,
95
 
        'remove_sec_loc': True
96
 
        }
97
 
 
98
 
wizard_replenish()
99
 
 
100
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
 
b'\\ No newline at end of file'