~stock-logistic-core-editors/stock-logistic-warehouse/7.0

« back to all changes in this revision

Viewing changes to stock_tracking_add_move/wizard/add_move.py

  • Committer: Mathieu Vatel
  • Date: 2012-03-07 12:56:37 UTC
  • Revision ID: mathieu@julius.fr-20120307125637-oz14go5k32kyqn2f
Extra modules Julius V1.0

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 Julius Network Solutions SARL <contact@julius.fr>
 
6
#
 
7
#    This program is free software: you can redistribute it and/or modify
 
8
#    it under the terms of the GNU General Public License as published by
 
9
#    the Free Software Foundation, either version 3 of the License, or
 
10
#    (at your option) any later version.
 
11
#
 
12
#    This program is distributed in the hope that it will be useful,
 
13
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
#    GNU General Public License for more details.
 
16
#
 
17
#    You should have received a copy of the GNU General Public License
 
18
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
#
 
20
#################################################################################
 
21
 
 
22
from osv import fields, osv
 
23
from tools.translate import _
 
24
 
 
25
class stock_packaging_move(osv.osv_memory):
 
26
 
 
27
    _name = "stock.packaging.move"
 
28
    
 
29
    _columns = {
 
30
        'reference': fields.char('Reference', size=128, required=True),
 
31
        'pack_id': fields.many2one('stock.tracking', 'Pack to move', required=True),
 
32
    }
 
33
    
 
34
    _defaults = {
 
35
        'pack_id': lambda s,cr,uid,c: c.get('active_id',False),
 
36
    }
 
37
    
 
38
    def add_move(self, cr, uid, ids, context=None):
 
39
        '''Init'''
 
40
        barcode_obj = self.pool.get('tr.barcode')
 
41
        tracking_obj = self.pool.get('stock.tracking')        
 
42
        if context == None:
 
43
            context = {}           
 
44
             
 
45
        '''Get parent id'''
 
46
        parent_id = context.get('active_id',False)        
 
47
        for obj in self.browse(cr, uid, ids):
 
48
            ref = obj.reference
 
49
            barcode_ids = barcode_obj.search(cr, uid, [('code', '=', ref)], limit=1)
 
50
            ''' Call for the adding function '''
 
51
            tracking_obj.add_validation(cr, uid, [parent_id], barcode_ids, context=None) 
 
52
        return {'type': 'ir.actions.act_window_close'}
 
53
    
 
54
    def remove_move(self, cr, uid, ids, context=None):
 
55
        '''Init'''
 
56
        barcode_obj = self.pool.get('tr.barcode')
 
57
        tracking_obj = self.pool.get('stock.tracking')
 
58
        move_obj = self.pool.get('stock.move')
 
59
        to_validate_obj = self.pool.get('stock.scan.to.validate')              
 
60
        if context == None:
 
61
            context = {}
 
62
            
 
63
        '''Get parent id'''
 
64
        parent_id = context.get('active_id',False)        
 
65
        for obj in self.browse(cr, uid, ids):
 
66
            ref = obj.reference
 
67
            barcode_ids = barcode_obj.search(cr, uid, [('code', '=', ref)], limit=1)
 
68
            ''' Call for the removal function '''
 
69
            tracking_obj.remove_validation(cr, uid, [parent_id], barcode_ids, context=None) 
 
70
        return {'type': 'ir.actions.act_window_close'}    
 
71
       
 
72
stock_packaging_move()
 
73
 
 
74
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
 
b'\\ No newline at end of file'