diff --git a/addons/mrp/__terp__.py b/addons/mrp/__terp__.py
index a8647098506..3bf2410cff9 100644
--- a/addons/mrp/__terp__.py
+++ b/addons/mrp/__terp__.py
@@ -60,7 +60,6 @@
'security/ir.model.access.csv',
'mrp_workflow.xml',
'mrp_data.xml',
- 'wizard/wizard_split_in_lots.xml',
'mrp_view.xml',
'mrp_wizard.xml',
'mrp_report.xml',
diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py
index e509c33740b..5e789c569da 100644
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@ -1354,10 +1354,10 @@ class StockMove(osv.osv):
for new in new_move:
production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new)]})
move_obj.action_done(cr, uid, [new])
- return new_move
+ return {}
- def split_moves(self, cr, uid, ids, datas, context=None):
- new_move = super(StockMove, self).split_moves(cr, uid, ids, datas, context=context)
+ def consume_moves(self, cr, uid, ids, product_qty, location_id, context=None):
+ new_move = super(StockMove, self).consume_moves(cr, uid, ids, product_qty, location_id, context=context)
if new_move:
production_obj = self.pool.get('mrp.production')
move_obj = self.pool.get('stock.move')
@@ -1366,8 +1366,8 @@ class StockMove(osv.osv):
production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]})
return {}
- def scrap_moves(self, cr, uid, ids, datas, context=None):
- new_move = super(StockMove, self).scrap_moves(cr, uid, ids, datas, context=context)
+ def scrap_moves(self, cr, uid, ids, product_qty, location_id, context=None):
+ new_move = super(StockMove, self).scrap_moves(cr, uid, ids, product_qty, location_id, context=context)
if new_move:
production_obj = self.pool.get('mrp.production')
move_obj = self.pool.get('stock.move')
diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index 843680c1f73..2ee0c1cd9fb 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -513,13 +513,8 @@
-
-
-
-
-
diff --git a/addons/mrp/wizard/__init__.py b/addons/mrp/wizard/__init__.py
index 274a245d4d0..240f25daa9d 100644
--- a/addons/mrp/wizard/__init__.py
+++ b/addons/mrp/wizard/__init__.py
@@ -27,7 +27,6 @@ import wizard_workcenter_load
import wizard_track_prod
import wizard_change_production_qty
import make_procurement
-import wizard_split_in_lots
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp/wizard/wizard_split_in_lots.py b/addons/mrp/wizard/wizard_split_in_lots.py
deleted file mode 100644
index be48cd15dff..00000000000
--- a/addons/mrp/wizard/wizard_split_in_lots.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero 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 Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-from osv import fields, osv
-from tools.translate import _
-import re
-import time
-import tools
-
-class spilt_in_lot(osv.osv_memory):
- _name = "spilt.in.lot"
- _description = "Split in lots"
-
- _columns = {
- 'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
- 'line_ids': fields.one2many('track.lines', 'lot_id', 'Lots Number')
- }
-
- def _get_product_id(self, cr, uid, context):
- move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
- return move.product_id.id
-
- _defaults = {
- 'product_id': _get_product_id,
- }
-
-spilt_in_lot()
-
-class track_lines(osv.osv_memory):
- _name = "track.lines"
- _description = "Track lines"
-
- _columns = {
- 'name': fields.char('Tracking serial', size=64),
- 'lot_id': fields.many2one('spilt.in.lot', 'Lot')
- }
-
-track_lines()
diff --git a/addons/mrp/wizard/wizard_split_in_lots.xml b/addons/mrp/wizard/wizard_split_in_lots.xml
deleted file mode 100644
index 5862a765839..00000000000
--- a/addons/mrp/wizard/wizard_split_in_lots.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
- Split in lots
- spilt.in.lot
- form
-
-
-
-
-
-
- Split in lots
- ir.actions.act_window
- spilt.in.lot
- form
- form
- new
-
-
-
-
\ No newline at end of file
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 66a65602e50..4c74e34b726 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1493,61 +1493,46 @@ class stock_move(osv.osv):
return super(stock_move, self).unlink(
cr, uid, ids, context=context)
- def _track_lines(self, cr, uid, ids, data, context=None):
- move_obj = self.pool.get('stock.move').browse(cr, uid, ids)
+ def _track_lines(self, cr, uid, ids, lines, context=None):
prodlot_obj = self.pool.get('stock.production.lot')
- ir_sequence_obj = self.pool.get('ir.sequence')
-
- sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
- if not sequence:
- raise wizard.except_wizard(_('Error!'), _('No production sequence defined'))
- if data['tracking_prefix']:
- sequence=data['tracking_prefix']+'/'+(sequence or '')
-
move = self.browse(cr, uid, [ids])[0]
-
- quantity=data['quantity']
- if quantity <= 0 or move.product_qty == 0:
- return {}
- uos_qty=quantity/move.product_qty*move.product_uos_qty
-
- quantity_rest = move.product_qty%quantity
- uos_qty_rest = quantity_rest/move.product_qty*move.product_uos_qty
-
- update_val = {
- 'product_qty': quantity,
- 'product_uos_qty': uos_qty,
- }
+ move_qty = move.product_qty
+ quantity_rest = move.product_qty
new_move = []
- for idx in range(int(move.product_qty//quantity)):
- if idx:
- current_move = self.copy(cr, uid, move.id, {'state': move.state})
- new_move.append(current_move)
- else:
- current_move = move.id
- new_prodlot = prodlot_obj.create(cr, uid, {'name': sequence, 'ref': '%d'%idx}, {'product_id': move.product_id.id})
- update_val['prodlot_id'] = new_prodlot
- self.write(cr, uid, [current_move], update_val)
-
+ for line in lines:
+ quantity = line['quantity']
+ sequence = line['tracking_num']
+ if quantity <= 0 or move_qty == 0:
+ continue
+ quantity_rest -= quantity
+ uos_qty = quantity / move_qty * move.product_uos_qty
+ uos_qty_rest = quantity_rest / move_qty * move.product_uos_qty
+ default_val = {
+ 'product_qty': quantity,
+ 'product_uos_qty': uos_qty,
+ 'state': move.state
+ }
+ current_move = self.copy(cr, uid, move.id, default_val)
+ new_move.append(current_move)
+ new_prodlot = prodlot_obj.create(cr, uid, {'name': sequence,
+ 'ref': '%d'%int(move_qty//quantity)},
+ {'product_id': move.product_id.id})
+ self.write(cr, uid, [current_move], {'prodlot_id': new_prodlot})
+
if quantity_rest > 0:
- idx = int(move.product_qty//quantity)
- update_val['product_qty']=quantity_rest
- update_val['product_uos_qty']=uos_qty_rest
- if idx:
- current_move = self.copy(cr, uid, move.id, {'state': move.state})
- new_move.append(current_move)
- else:
- current_move = move.id
- new_prodlot = prodlot_obj.create(cr, uid, {'name': sequence, 'ref': '%d'%idx}, {'product_id': move.product_id.id})
- update_val['prodlot_id'] = new_prodlot
- self.write(cr, uid, [current_move], update_val)
+ new_prodlot = prodlot_obj.create(cr, uid, {'name': sequence + '/', 'ref': '%d' % int(move_qty//quantity)}, {'product_id': move.product_id.id})
+ update_val= {'prodlot_id': new_prodlot,
+ 'product_qty': quantity_rest,
+ 'product_uos_qty': uos_qty_rest
+ }
+ self.write(cr, uid, [move.id], update_val)
return new_move
- def split_moves(self, cr, uid, ids, datas, context=None):
+ def consume_moves(self, cr, uid, ids, product_qty, location_id, context=None):
new_move = None
if not context:
context = {}
- qty = datas['product_qty']
+ qty = product_qty
if qty <= 0:
raise wizard.except_wizard(_('Warning!'), _('Please provide Proper Quantity !'))
@@ -1563,7 +1548,7 @@ class stock_move(osv.osv):
vals = {
'product_qty' : qty,
'product_uos_qty': qty,
- 'location_id': datas['location_id'],
+ 'location_id': location_id
}
track = move.product_id.track_production
self.write(cr, uid, move.id, vals)
@@ -1579,9 +1564,9 @@ class stock_move(osv.osv):
new_move = self.copy(cr, uid, move.id, default=defaults)
return new_move
- def scrap_moves(self, cr, uid, ids, datas, context=None):
+ def scrap_moves(self, cr, uid, ids, product_qty, location_id, context=None):
new_move = None
- qty = datas['product_qty']
+ qty = product_qty
if qty <= 0:
raise wizard.except_wizard(_('Warning!'), _('Please provide Proper Quantity !'))
@@ -1598,7 +1583,7 @@ class stock_move(osv.osv):
vals = {
'product_qty': qty,
'state': move.state,
- 'location_dest_id': datas['location_id']
+ 'location_dest_id': location_id
}
self.write(cr, uid, ids, vals)
diff --git a/addons/stock/stock_osv_wizards.xml b/addons/stock/stock_osv_wizards.xml
index ad5b74a6cce..6b5694f76df 100644
--- a/addons/stock/stock_osv_wizards.xml
+++ b/addons/stock/stock_osv_wizards.xml
@@ -20,7 +20,7 @@
-
+
Tracking a move
ir.actions.act_window
stock.move.track
@@ -49,7 +49,7 @@
-
@@ -98,5 +98,42 @@
new
+
+ Split in lots
+ spilt.in.lot
+ form
+
+
+
+
+
+
+ Split in lots
+ ir.actions.act_window
+ spilt.in.lot
+ form
+ form
+ new
+
+
\ No newline at end of file
diff --git a/addons/stock/stock_wizard.py b/addons/stock/stock_wizard.py
index be0d98ca7c7..278b9b22fd8 100644
--- a/addons/stock/stock_wizard.py
+++ b/addons/stock/stock_wizard.py
@@ -80,10 +80,12 @@ class stock_move_consume(osv.osv_memory):
'location_id': _get_location_id
}
- def move_consume(self, cr, uid, ids, context={}):
+ def do_move_consume(self, cr, uid, ids, context={}):
datas = self.read(cr, uid, ids)[0]
move_obj = self.pool.get('stock.move')
- move_obj.split_moves(cr, uid, context['active_id'], datas, context=context)
+ move_obj.consume_moves(cr, uid, context['active_id'],
+ datas['product_qty'], datas['location_id'],
+ context=context)
return {}
stock_move_consume()
@@ -101,7 +103,50 @@ class stock_move_scrap(osv.osv_memory):
def move_scrap(self, cr, uid, ids, context={}):
datas = self.read(cr, uid, ids)[0]
move_obj = self.pool.get('stock.move')
- move_obj.scrap_moves(cr, uid, context['active_id'], datas, context=context)
+ move_obj.scrap_moves(cr, uid, context['active_id'],
+ datas['product_qty'], datas['location_id'],
+ context=context)
return {}
-stock_move_scrap()
\ No newline at end of file
+stock_move_scrap()
+
+
+class spilt_in_lot(osv.osv_memory):
+ _name = "spilt.in.lot"
+ _description = "Split in lots"
+
+ _columns = {
+ 'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
+ 'line_ids': fields.one2many('track.lines', 'lot_id', 'Lots Number')
+ }
+
+ def _get_product_id(self, cr, uid, context):
+ move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
+ return move.product_id.id
+
+ _defaults = {
+ 'product_id': _get_product_id,
+ }
+
+ def split_lot(self, cr, uid, ids, context=None):
+ datas = self.read(cr, uid, ids)[0]
+ lines = []
+ for line in self.pool.get('track.lines').browse(cr, uid, datas.get('line_ids', [])):
+ lines.append({'tracking_num': line.name, 'quantity': line.quantity})
+ move_obj = self.pool.get('stock.move')
+ move_obj._track_lines(cr, uid, context['active_id'], lines, context=context)
+ return {}
+
+spilt_in_lot()
+
+class track_lines(osv.osv_memory):
+ _name = "track.lines"
+ _description = "Track lines"
+
+ _columns = {
+ 'name': fields.char('Tracking serial', size=64),
+ 'quantity': fields.integer('Quantity'),
+ 'lot_id': fields.many2one('spilt.in.lot', 'Lot')
+ }
+
+track_lines()