[REMOVE] Remove split wizards
bzr revid: jco@openerp.com-20140129134424-c72zk1z2n3rixnwg
This commit is contained in:
parent
3590a5ff93
commit
5626d63634
|
@ -196,20 +196,6 @@ class StockPicking(osv.osv):
|
|||
return list(set(todo))
|
||||
|
||||
|
||||
class split_in_production_lot(osv.osv_memory):
|
||||
_inherit = "stock.move.split"
|
||||
|
||||
def split(self, cr, uid, ids, move_ids, context=None):
|
||||
""" Splits move lines into given quantities.
|
||||
@param move_ids: Stock moves.
|
||||
@return: List of new moves.
|
||||
"""
|
||||
new_moves = super(split_in_production_lot, self).split(cr, uid, ids, move_ids, context=context)
|
||||
production_obj = self.pool.get('mrp.production')
|
||||
production_ids = production_obj.search(cr, uid, [('move_lines', 'in', move_ids)])
|
||||
production_obj.write(cr, uid, production_ids, {'move_lines': [(4, m) for m in new_moves]})
|
||||
return new_moves
|
||||
|
||||
|
||||
class stock_warehouse(osv.osv):
|
||||
_inherit = 'stock.warehouse'
|
||||
|
|
|
@ -89,137 +89,5 @@ class stock_move_scrap(osv.osv_memory):
|
|||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
||||
class split_in_production_lot(osv.osv_memory):
|
||||
_name = "stock.move.split"
|
||||
_description = "Split in Serial Numbers"
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = super(split_in_production_lot, self).default_get(cr, uid, fields, context=context)
|
||||
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})
|
||||
if 'location_id' in fields:
|
||||
res.update({'location_id': move.location_id.id})
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure')),
|
||||
'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
|
||||
'product_uom': fields.many2one('product.uom', 'Unit of Measure'),
|
||||
'line_ids': fields.one2many('stock.move.split.lines', 'wizard_id', 'Serial Numbers'),
|
||||
'line_exist_ids': fields.one2many('stock.move.split.lines', 'wizard_exist_id', 'Serial Numbers'),
|
||||
'use_exist' : fields.boolean('Existing Serial Numbers',
|
||||
help="Check this option to select existing serial numbers in the list below, otherwise you should enter new ones line by line."),
|
||||
'location_id': fields.many2one('stock.location', 'Source Location')
|
||||
}
|
||||
|
||||
def split_lot(self, cr, uid, ids, context=None):
|
||||
""" To split a lot"""
|
||||
if context is None:
|
||||
context = {}
|
||||
res = self.split(cr, uid, ids, context.get('active_ids'), context=context)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
def split(self, cr, uid, ids, move_ids, context=None):
|
||||
""" To split stock moves into serial numbers
|
||||
|
||||
:param move_ids: the ID or list of IDs of stock move we want to split
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
assert context.get('active_model') == 'stock.move',\
|
||||
'Incorrect use of the stock move split wizard'
|
||||
inventory_id = context.get('inventory_id', False)
|
||||
prodlot_obj = self.pool.get('stock.production.lot')
|
||||
inventory_obj = self.pool.get('stock.inventory')
|
||||
move_obj = self.pool.get('stock.move')
|
||||
new_move = []
|
||||
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
|
||||
new_move = []
|
||||
if data.use_exist:
|
||||
lines = [l for l in data.line_exist_ids if l]
|
||||
else:
|
||||
lines = [l for l in data.line_ids if l]
|
||||
total_move_qty = 0.0
|
||||
for line in lines:
|
||||
quantity = line.quantity
|
||||
total_move_qty += quantity
|
||||
if total_move_qty > move_qty:
|
||||
raise osv.except_osv(_('Processing Error!'), _('Serial number quantity %d of %s is larger than available quantity (%d)!') \
|
||||
% (total_move_qty, move.product_id.name, move_qty))
|
||||
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
|
||||
if quantity_rest < 0:
|
||||
quantity_rest = quantity
|
||||
self.pool.get('stock.move').log(cr, uid, move.id, _('Unable to assign all lots to this move!'))
|
||||
return False
|
||||
default_val = {
|
||||
'product_qty': quantity,
|
||||
'product_uos_qty': uos_qty,
|
||||
'state': move.state
|
||||
}
|
||||
if quantity_rest > 0:
|
||||
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
|
||||
lot_id = False
|
||||
if data.use_exist:
|
||||
lot_id = line.lot_id.id
|
||||
if not lot_id:
|
||||
lot_id = prodlot_obj.create(cr, uid, {
|
||||
'name': line.name,
|
||||
'product_id': move.product_id.id},
|
||||
context=context)
|
||||
|
||||
move_obj.write(cr, uid, [current_move], {'lot_id': lot_id, 'state':move.state})
|
||||
|
||||
update_val = {}
|
||||
if quantity_rest > 0:
|
||||
update_val['product_qty'] = quantity_rest
|
||||
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
|
||||
|
||||
|
||||
class stock_move_split_lines_exist(osv.osv_memory):
|
||||
_name = "stock.move.split.lines"
|
||||
_description = "Stock move Split lines"
|
||||
_columns = {
|
||||
'name': fields.char('Serial Number', size=64),
|
||||
'quantity': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure')),
|
||||
'wizard_id': fields.many2one('stock.move.split', 'Parent Wizard'),
|
||||
'wizard_exist_id': fields.many2one('stock.move.split', 'Parent Wizard (for existing lines)'),
|
||||
'lot_id': fields.many2one('stock.production.lot', 'Serial Number'),
|
||||
}
|
||||
_defaults = {
|
||||
'quantity': 1.0,
|
||||
}
|
||||
|
||||
def onchange_lot_id(self, cr, uid, ids, lot_id=False, product_qty=False,
|
||||
loc_id=False, product_id=False, uom_id=False,context=None):
|
||||
return self.pool.get('stock.move').onchange_lot_id(cr, uid, [], lot_id, product_qty,
|
||||
loc_id, product_id, uom_id, context)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -40,62 +40,5 @@
|
|||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record id="view_split_in_lots" model="ir.ui.view">
|
||||
<field name="name">Split in Serial Numbers</field>
|
||||
<field name="model">stock.move.split</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Split in Serial Numbers" version="7.0">
|
||||
<group>
|
||||
<field name="product_id" readonly="1"/>
|
||||
<label for="qty"/>
|
||||
<div>
|
||||
<field name="qty" readonly="1" class="oe_inline"/>
|
||||
<field name="product_uom" readonly="1" class="oe_inline"/>
|
||||
</div>
|
||||
<field name="location_id" invisible="1"/>
|
||||
<field name="use_exist"/>
|
||||
</group>
|
||||
<field name="line_ids" attrs="{'invisible':[('use_exist','=',True)]}">
|
||||
<tree string="Serial Numbers" editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="quantity" />
|
||||
</tree>
|
||||
<form string="Serial Number" version="7.0">
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="quantity" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
<field name="line_exist_ids" attrs="{'invisible':[('use_exist','!=',True)]}">
|
||||
<tree string="Serial Numbers" editable="bottom">
|
||||
<field name="lot_id" string="Serial Number" quick_create="false" domain="[('product_id','=',parent.product_id)]" on_change="onchange_lot_id(lot_id, quantity, parent.location_id, parent.product_id, parent.product_uom, context)" context="{'product_id': parent.product_id}"/>
|
||||
<field name="quantity" on_change="onchange_lot_id(lot_id, quantity, parent.location_id, parent.product_id, parent.product_uom,context)" />
|
||||
</tree>
|
||||
<form string="Serial Number" version="7.0">
|
||||
<group>
|
||||
<field name="lot_id" domain="[('product_id','=',parent.product_id)]" on_change="onchange_lot_id(lot_id, quantity, parent.location_id, parent.product_id, parent.product_uom, context)"/>
|
||||
<field name="quantity" on_change="onchange_lot_id(lot_id, quantity, parent.location_id, parent.product_id, parent.product_uom, context)" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
<footer>
|
||||
<button name="split_lot" string="Split" type="object" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="track_line" model="ir.actions.act_window">
|
||||
<field name="name">Split in Serial Numbers</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">stock.move.split</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue