[IMP] stock: split inventory line
bzr revid: hmo@tinyerp.com-20100708071321-9ivz72r32l38ryx8
This commit is contained in:
parent
96f31d2880
commit
cb6add0765
|
@ -2229,6 +2229,7 @@ class stock_inventory(osv.osv):
|
|||
|
||||
# price = line.product_id.standard_price or 0.0
|
||||
amount = self.pool.get('stock.location')._product_get(cr, uid, line.location_id.id, [pid], {'uom': line.product_uom.id})[pid]
|
||||
#TOCHECK: Why put restriction like new inventory qty should greater available qty ?
|
||||
change = line.product_qty - amount
|
||||
lot_id = line.prod_lot_id.id
|
||||
if change:
|
||||
|
|
|
@ -47,7 +47,11 @@ class stock_inventory_line_split(osv.osv_memory):
|
|||
res = {}
|
||||
line = self.pool.get('stock.inventory.line').browse(cr, uid, record_id)
|
||||
if 'product_id' in fields:
|
||||
res.update({'product_id':line.product_id.id})
|
||||
res.update({'product_id':line.product_id.id})
|
||||
if 'product_uom' in fields:
|
||||
res.update({'product_uom': line.product_uom.id})
|
||||
if 'qty' in fields:
|
||||
res.update({'qty': line.product_qty})
|
||||
return res
|
||||
|
||||
def split(self, cr, uid, ids, line_ids, context=None):
|
||||
|
@ -68,11 +72,13 @@ class stock_inventory_line_split(osv.osv_memory):
|
|||
for inv_line in line_obj.browse(cr, uid, line_ids):
|
||||
line_qty = inv_line.product_qty
|
||||
quantity_rest = inv_line.product_qty
|
||||
new_line = []
|
||||
for line in data.line_ids:
|
||||
new_line = []
|
||||
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]
|
||||
for line in lines:
|
||||
quantity = line.quantity
|
||||
|
||||
|
||||
if quantity <= 0 or line_qty == 0:
|
||||
continue
|
||||
quantity_rest -= quantity
|
||||
|
@ -85,14 +91,13 @@ class stock_inventory_line_split(osv.osv_memory):
|
|||
current_line = line_obj.copy(cr, uid, inv_line.id, default_val)
|
||||
new_line.append(current_line)
|
||||
prodlot_id = False
|
||||
if line.use_exist and line.name:
|
||||
prodlot_id = prodlot_obj.search(cr, uid, [('prefix','=',line.name),('product_id','=',data.product_id.id)])
|
||||
if prodlot_id:
|
||||
prodlot_id = prodlot_id[0]
|
||||
if data.use_exist:
|
||||
prodlot_id = line.prodlot_id.id
|
||||
if not prodlot_id:
|
||||
sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
|
||||
prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix' : line.name},
|
||||
{'product_id': data.product_id.id})
|
||||
prodlot_id = prodlot_obj.create(cr, uid, {
|
||||
'name': line.name,
|
||||
'product_id': inv_line.product_id.id},
|
||||
context=context)
|
||||
line_obj.write(cr, uid, [current_line], {'prod_lot_id': prodlot_id})
|
||||
prodlot = prodlot_obj.browse(cr, uid, prodlot_id)
|
||||
|
||||
|
|
|
@ -1,38 +1,61 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_stock_inventory_line_split" model="ir.ui.view">
|
||||
<field name="name">Split inventory lines</field>
|
||||
<field name="model">stock.inventory.line.split</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Split inventory lines in lots">
|
||||
<field name="product_id" colspan="4" readonly="1"/>
|
||||
<newline/>
|
||||
<field name="line_ids" colspan="4" nolabel="1">
|
||||
<tree string="Lots Number" editable="top">
|
||||
<field name="name" string="Lots"/>
|
||||
<field name="quantity" />
|
||||
<field name="use_exist" />
|
||||
</tree>
|
||||
<form string="Lots Number">
|
||||
<field name="name" string="Lots"/>
|
||||
<field name="quantity" />
|
||||
<field name="use_exist" />
|
||||
</form>
|
||||
</field>
|
||||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2" />
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="split_lot" string="Ok"
|
||||
type="object" icon="gtk-ok" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="view_split_in_lots_inherit" model="ir.ui.view">
|
||||
<field name="name">Split Inventory Line</field>
|
||||
<field name="model">stock.inventory.line.split</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Split in lots">
|
||||
<group width="660" height="275">
|
||||
<field name="product_id" colspan="4" readonly="1"/>
|
||||
<newline/>
|
||||
<group colspan="4" col="4">
|
||||
<group colspan="1" col="2">
|
||||
<field name="use_exist"/>
|
||||
</group>
|
||||
<group colspan="1" col="2">
|
||||
<field name="qty" readonly="1"/>
|
||||
</group>
|
||||
<group colspan="1" col="2">
|
||||
<field name="product_uom" readonly="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<group colspan="4" attrs="{'invisible':[('use_exist','=',True)]}">
|
||||
<field name="line_ids" colspan="4" nolabel="1">
|
||||
<tree string="Lots Number" editable="bottom">
|
||||
<field name="name" string="Lots"/>
|
||||
<field name="quantity" />
|
||||
</tree>
|
||||
<form string="Lots Number">
|
||||
<field name="name" string="Lots"/>
|
||||
<field name="quantity" />
|
||||
</form>
|
||||
</field>
|
||||
</group>
|
||||
<group colspan="4" attrs="{'invisible':[('use_exist','!=',True)]}">
|
||||
<field name="line_exist_ids" colspan="4" nolabel="1">
|
||||
<tree string="Lots Number" editable="bottom">
|
||||
<field name="prodlot_id" string="Lots" domain="[('product_id','=',parent.product_id)]"/>
|
||||
<field name="quantity" />
|
||||
</tree>
|
||||
<form string="Lots Number">
|
||||
<field name="prodlot_id" string="Lots" domain="[('product_id','=',parent.product_id)]"/>
|
||||
<field name="quantity" />
|
||||
</form>
|
||||
</field>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2" />
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="split_lot" string="Ok"
|
||||
type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_stock_inventory_line_split" model="ir.actions.act_window">
|
||||
<field name="name">Split inventory lines</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
|
|
Loading…
Reference in New Issue