Files
stock-logistics-warehouse/stock_tracking_add_move/wizard/add_move.py
2012-03-07 13:56:37 +01:00

74 lines
3.0 KiB
Python

# -*- coding: utf-8 -*-
#################################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU 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 stock_packaging_move(osv.osv_memory):
_name = "stock.packaging.move"
_columns = {
'reference': fields.char('Reference', size=128, required=True),
'pack_id': fields.many2one('stock.tracking', 'Pack to move', required=True),
}
_defaults = {
'pack_id': lambda s,cr,uid,c: c.get('active_id',False),
}
def add_move(self, cr, uid, ids, context=None):
'''Init'''
barcode_obj = self.pool.get('tr.barcode')
tracking_obj = self.pool.get('stock.tracking')
if context == None:
context = {}
'''Get parent id'''
parent_id = context.get('active_id',False)
for obj in self.browse(cr, uid, ids):
ref = obj.reference
barcode_ids = barcode_obj.search(cr, uid, [('code', '=', ref)], limit=1)
''' Call for the adding function '''
tracking_obj.add_validation(cr, uid, [parent_id], barcode_ids, context=None)
return {'type': 'ir.actions.act_window_close'}
def remove_move(self, cr, uid, ids, context=None):
'''Init'''
barcode_obj = self.pool.get('tr.barcode')
tracking_obj = self.pool.get('stock.tracking')
move_obj = self.pool.get('stock.move')
to_validate_obj = self.pool.get('stock.scan.to.validate')
if context == None:
context = {}
'''Get parent id'''
parent_id = context.get('active_id',False)
for obj in self.browse(cr, uid, ids):
ref = obj.reference
barcode_ids = barcode_obj.search(cr, uid, [('code', '=', ref)], limit=1)
''' Call for the removal function '''
tracking_obj.remove_validation(cr, uid, [parent_id], barcode_ids, context=None)
return {'type': 'ir.actions.act_window_close'}
stock_packaging_move()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: