##############################################################################
from osv import fields, osv
-from tools.translate import _
class stock_move_track(osv.osv_memory):
_name = "stock.move.track"
'quantity': lambda *x: 1
}
- def track_lines(self, cr, uid, ids, context={}):
+ def track_lines(self, cr, uid, ids, context=None):
""" To track stock moves lines
@param self: The object pointer.
@param cr: A database cursor
datas = self.read(cr, uid, ids)[0]
move_obj = self.pool.get('stock.move')
move_obj._track_lines(cr, uid, context['active_id'], datas, context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
stock_move_track()
@param context: A standard dictionary
@return: default values of fields
"""
+ if context is None:
+ context = {}
res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context)
move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
if 'product_id' in fields:
return res
- def do_move_consume(self, cr, uid, ids, context={}):
+ def do_move_consume(self, cr, uid, ids, context=None):
""" To move consumed products
@param self: The object pointer.
@param cr: A database cursor
@param context: A standard dictionary
@return:
"""
+ if context is None:
+ context = {}
move_obj = self.pool.get('stock.move')
move_ids = context['active_ids']
for data in self.read(cr, uid, ids):
move_obj.action_consume(cr, uid, move_ids,
data['product_qty'], data['location_id'],
context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
stock_move_consume()
@param context: A standard dictionary
@return: default values of fields
"""
+ if context is None:
+ context = {}
res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context)
move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
location_obj = self.pool.get('stock.location')
return res
- def move_scrap(self, cr, uid, ids, context={}):
- """ To move scraped products
+ def move_scrap(self, cr, uid, ids, context=None):
+ """ To move scrapped products
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return:
"""
+ if context is None:
+ context = {}
move_obj = self.pool.get('stock.move')
move_ids = context['active_ids']
for data in self.read(cr, uid, ids):
move_obj.action_scrap(cr, uid, move_ids,
data['product_qty'], data['location_id'],
context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
stock_move_scrap()
@param context: A standard dictionary
@return: Default values of fields
"""
+ if context is None:
+ context = {}
res = super(split_in_production_lot, self).default_get(cr, uid, fields, context=context)
- move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
- if 'product_id' in fields:
- res.update({'product_id': move.product_id.id})
- if 'product_uom' in fields:
- res.update({'product_uom': move.product_uom.id})
- if 'qty' in fields:
- res.update({'qty': move.product_qty})
- if 'use_exist' in fields:
- res.update({'use_exist': (move.picking_id and move.picking_id.type=='out' and True) or False})
+ if context.get('active_id'):
+ move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
+ if 'product_id' in fields:
+ res.update({'product_id': move.product_id.id})
+ if 'product_uom' in fields:
+ res.update({'product_uom': move.product_uom.id})
+ if 'qty' in fields:
+ res.update({'qty': move.product_qty})
+ if 'use_exist' in fields:
+ res.update({'use_exist': (move.picking_id and move.picking_id.type=='out' and True) or False})
return res
_columns = {
'qty': fields.integer('Quantity'),
'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
- 'product_uom': fields.many2one('product.uom', 'Product UOM'),
- 'line_ids': fields.one2many('stock.move.split.lines', 'lot_id', 'Lots Number'),
- 'line_exist_ids': fields.one2many('stock.move.split.lines.exist', 'lot_id', 'Lots Existing Numbers'),
- 'use_exist' : fields.boolean('Use Exist'),
+ 'product_uom': fields.many2one('product.uom', 'UoM'),
+ 'line_ids': fields.one2many('stock.move.split.lines', 'lot_id', 'Production Lots'),
+ 'line_exist_ids': fields.one2many('stock.move.split.lines.exist', 'lot_id', 'Production Lots'),
+ 'use_exist' : fields.boolean('Existing Lots', help="Check this option to select existing lots in the list below, otherwise you should enter new ones line by line."),
}
def split_lot(self, cr, uid, ids, context=None):
@param context: A standard dictionary
@return:
"""
+ if context is None:
+ context = {}
self.split(cr, uid, ids, context.get('active_ids'), context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
def split(self, cr, uid, ids, move_ids, context=None):
""" To split stock moves into production lot
@param context: A standard dictionary
@return:
"""
+ if context is None:
+ context = {}
+ inventory_id = context.get('inventory_id', False)
prodlot_obj = self.pool.get('stock.production.lot')
- ir_sequence_obj = self.pool.get('ir.sequence')
+ inventory_obj = self.pool.get('stock.inventory')
move_obj = self.pool.get('stock.move')
new_move = []
- for data in self.browse(cr, uid, ids):
- for move in move_obj.browse(cr, uid, move_ids):
+ for data in self.browse(cr, uid, ids, context=context):
+ for move in move_obj.browse(cr, uid, move_ids, context=context):
move_qty = move.product_qty
quantity_rest = move.product_qty
uos_qty_rest = move.product_uos_qty
'state': move.state
}
if quantity_rest > 0:
- current_move = move_obj.copy(cr, uid, move.id, default_val)
+ current_move = move_obj.copy(cr, uid, move.id, default_val, context=context)
+ if inventory_id and current_move:
+ inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, current_move)]}, context=context)
new_move.append(current_move)
+
if quantity_rest == 0:
current_move = move.id
prodlot_id = False
'name': line.name,
'product_id': move.product_id.id},
context=context)
- print 'write', current_move, {'prodlot_id': prodlot_id, 'state':move.state}
+
move_obj.write(cr, uid, [current_move], {'prodlot_id': prodlot_id, 'state':move.state})
update_val = {}
update_val['product_uos_qty'] = uos_qty_rest
update_val['state'] = move.state
move_obj.write(cr, uid, [move.id], update_val)
+
return new_move
+
split_in_production_lot()
class stock_move_split_lines_exist(osv.osv_memory):
_columns = {
'name': fields.char('Tracking serial', size=64),
'quantity': fields.integer('Quantity'),
- 'use_exist' : fields.boolean('Use Exist'),
+ 'use_exist' : fields.boolean('Existing Lot'),
'lot_id': fields.many2one('stock.move.split', 'Lot'),
'action': fields.selection([('split','Split'),('keepinone','Keep in one lot')],'Action'),
}