[IMP] stock: 1) Improvement in reception move line, 2) Added new osv memoery wizard for slilt move lines in production lots, 3) Set the lines in the physical inventory as an editable list.

bzr revid: hmo@tinyerp.com-20100117073914-g4ss15s9tg733skr
This commit is contained in:
Harry (Open ERP) 2010-01-17 13:09:14 +05:30
parent 9e2b2cf239
commit 0dec1a890e
2 changed files with 180 additions and 25 deletions

View File

@ -901,6 +901,71 @@ class stock_production_lot(osv.osv):
stock_production_lot()
class stock_split_production_lots(osv.osv_memory):
_name = "stock.split.production.lots"
_description = "Split Production Lots"
def _quantity_default_get(self, cr, uid, object=False, field=False, context=None):
cr.execute("select %s from %s where id=%s" %(field,object,context.get('active_id')))
res = cr.fetchone()[0]
return res
_columns = {
'name': fields.char('Lot Number/Prefix', size=64, required=True),
'qty': fields.float('Total Quantity'),
'action': fields.selection([('split','Split'),('keepinone','Keep in one lot')],'Action'),
}
_defaults = {
'qty': lambda self,cr,uid,c: self.pool.get('stock.split.production.lots')._quantity_default_get(cr, uid, 'stock_move', 'product_qty',context=c) or 1,
}
def split_lines(self, cr, uid, ids, context={}):
data = self.read(cr, uid, ids[0])
prodlot_obj = self.pool.get('stock.production.lot')
move_obj = self.pool.get('stock.move')
move_browse = move_obj.browse(cr, uid, context['active_id'])
quantity = data['qty']
if quantity <= 0 or move_browse.product_qty == 0:
return {}
uos_qty = quantity/move_browse.product_qty*move_browse.product_uos_qty
quantity_rest = move_browse.product_qty%quantity
uos_qty_rest = quantity_rest/move_browse.product_qty*move_browse.product_uos_qty
update_val = {
'product_qty': quantity,
'product_uos_qty': uos_qty,
}
new_move = []
for idx in range(int(move_browse.product_qty//quantity)):
if idx:
current_move = move_obj.copy(cr, uid, move_browse.id, {'state': move_browse.state})
new_move.append(current_move)
else:
current_move = move_browse.id
new_prodlot = prodlot_obj.create(cr, uid, {'name': data['name'], 'ref': '%d'%idx}, {'product_id': move_browse.product_id.id})
update_val['prodlot_id'] = new_prodlot
move_obj.write(cr, uid, [current_move], update_val)
if quantity_rest > 0:
idx = int(move_browse.product_qty//quantity)
update_val['product_qty'] = quantity_rest
update_val['product_uos_qty'] = uos_qty_rest
if idx:
current_move = move_obj.copy(cr, uid, move_browse.id, {'state': move_browse.state})
new_move.append(current_move)
else:
current_move = move_browse.id
new_prodlot = prodlot_obj.create(cr, uid, {'name': data['name'], 'ref': '%d'%idx}, {'product_id': move_browse.product_id.id})
update_val['prodlot_id'] = new_prodlot
move_obj.write(cr, uid, [current_move], update_val)
return {}
stock_split_production_lots()
class stock_production_lot_revision(osv.osv):
_name = 'stock.production.lot.revision'
@ -1070,7 +1135,7 @@ class stock_move(osv.osv):
cursor.commit()
return res
def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, loc_id=False, context=None):
def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, loc_id=False, product_id=False, context=None):
if not prodlot_id or not loc_id:
return {}
ctx = context and context.copy() or {}
@ -1275,7 +1340,9 @@ class stock_move(osv.osv):
def action_done(self, cr, uid, ids, context=None):
track_flag = False
picking_ids = []
for move in self.browse(cr, uid, ids):
if move.picking_id: picking_ids.append(move.picking_id.id)
if move.move_dest_id.id and (move.state != 'done'):
cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id))
if move.move_dest_id.state in ('waiting', 'confirmed'):
@ -1373,7 +1440,11 @@ class stock_move(osv.osv):
'line_id': lines,
'ref': ref,
})
self.write(cr, uid, ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')})
self.write(cr, uid, ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')})
for pick in self.pool.get('stock.picking').browse(cr, uid, picking_ids):
if all(move.state == 'done' for move in pick.move_lines):
self.pool.get('stock.picking').action_done(cr, uid, [pick.id])
wf_service = netsvc.LocalService("workflow")
for id in ids:
wf_service.trg_trigger(uid, 'stock.move', id, cr)
@ -1397,7 +1468,7 @@ class stock_inventory(osv.osv):
'name': fields.char('Inventory', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
'date': fields.datetime('Date create', required=True, readonly=True, states={'draft': [('readonly', False)]}),
'date_done': fields.datetime('Date done'),
'inventory_line_id': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', readonly=True, states={'draft': [('readonly', False)]}),
'inventory_line_id': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', states={'draft': [('readonly', False)]}),
'move_ids': fields.many2many('stock.move', 'stock_inventory_move_rel', 'inventory_id', 'move_id', 'Created Moves'),
'state': fields.selection( (('draft', 'Draft'), ('done', 'Done'), ('cancel','Cancelled')), 'State', readonly=True),
'company_id': fields.many2one('res.company','Company',required=True,select=1),

View File

@ -17,10 +17,10 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Stock Inventory Lines">
<field name="location_id"/>
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field name="location_id"/>
</tree>
</field>
</record>
@ -30,10 +30,10 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Stock Inventory Lines">
<field colspan="4" domain="[('usage','=','internal')]" name="location_id" select="1"/>
<field context="location=location_id,uom=product_uom" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom)" select="1" domain="[('type','&lt;&gt;','service')]"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field colspan="4" domain="[('usage','=','internal')]" name="location_id" select="1"/>
</form>
</field>
</record>
@ -64,7 +64,20 @@
<field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
<notebook colspan="4">
<page string="General Informations">
<field colspan="4" name="inventory_line_id" nolabel="1" widget="one2many_list"/>
<field colspan="4" name="inventory_line_id" nolabel="1" widget="one2many_list">
<tree string="Inventory Lines" editable="bottom">
<field context="location=location_id,uom=product_uom" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom)" select="1" domain="[('type','&lt;&gt;','service')]"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field colspan="4" domain="[('usage','=','internal')]" name="location_id" select="1"/>
</tree>
<form string="Inventory Lines">
<field context="location=location_id,uom=product_uom" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom)" select="1" domain="[('type','&lt;&gt;','service')]"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field colspan="4" domain="[('usage','=','internal')]" name="location_id" select="1"/>
</form>
</field>
</page><page string="Posted Inventory">
<field colspan="4" name="move_ids" nolabel="1"/>
</page>
@ -485,6 +498,32 @@
=============================
Picking
=============================
<record id="view_stock_split_production_lots" model="ir.ui.view">
<field name="name">Split Production Lots</field>
<field name="model">stock.split.production.lots</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Split Production Lots">
<group col="4" colspan="4">
<field name="name"/>
<field name="qty" attrs="{'readonly':[('action','!=','split')]}"/>
<field name="action" colspan="4"/>
</group>
<newline/>
<button name="split_lines" string="Ok" type="object" icon="gtk-go-forward"/>
</form>
</field>
</record>
<record id="action_view_stock_split_production_lots" model="ir.actions.act_window">
<field name="name">Split Production Lots</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.split.production.lots</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record model="ir.ui.view" id="stock_picking_calendar">
<field name="name">stock.picking.calendar</field>
<field name="model">stock.picking</field>
@ -1243,11 +1282,11 @@
</record>
<menuitem action="action_picking_all" id="menu_action_picking_all" parent="menu_stock_warehouse_mgmt" sequence="3"/>
====================================
====================================
Reception Picking (By Stock Move)
====================================
<record id="view_move_tree_reception_picking" model="ir.ui.view">
<record id="view_move_tree_reception_picking" model="ir.ui.view">
<field name="name">stock.move.tree2</field>
<field name="model">stock.move</field>
<field name="type">tree</field>
@ -1263,33 +1302,65 @@
<field name="prodlot_id" string="Lot"/>
<field name="date_planned"/>
<field name="backorder_id"/>
<field name="state"/>
<button name="action_done" states="done" string="Done" type="object" icon="gtk-close"/>
<button name="%(partial_move)d" string="Partial" type="action" icon="gtk-justify-fill"/>
<field name="state"/>
<button name="%(partial_move)d" string="Partial" type="action" states="assigned" icon="gtk-justify-fill"/>
<button name="action_cancel" states="assigned,confirmed" string="Cancel" type="object" icon="gtk-cancel"/>
</tree>
</field>
</record>
<record id="view_move_form_reception_picking" model="ir.ui.view">
<record id="view_move_form_reception_picking" model="ir.ui.view">
<field name="name">stock.move.form2</field>
<field name="model">stock.move</field>
<field name="type">form</field>
<field eval="6" name="priority"/>
<field name="arch" type="xml">
<form string="Moves">
<field name="picking_id"/>
<field name="product_id"/>
<field name="product_qty" />
<field name="product_uom" string="UOM"/>
<field name="prodlot_id"/>
<field name="date_planned"/>
<field name="state"/>
<notebook colspan="4">
<page string="General Information">
<separator colspan="4" string="Move Information"/>
<field name="location_id" select="1"/>
<field name="location_dest_id" select="1"/>
<field colspan="4" name="product_id" select="1"/>
<field name="product_qty" select="2" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
<field name="product_uom" select="2"/>
<field name="product_uos" select="2"/>
<field colspan="4" name="name" select="2"/>
<field name="date"/>
<field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
<field name="date_planned"/>
<field name="priority"/>
<field name="address_id" select="2" context="{'contact_display':'partner'}"/>
<newline/>
<field name="picking_id" select="2"/>
<newline/>
<field name="prodlot_id" select="2"
context="{'location_id':location_id, 'product_id':product_id}"
domain="[('product_id','=?',product_id)]"
on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)"/>
<field name="tracking_id" select="2"/>
<newline/>
<label/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill"/>
<separator colspan="4" string="Move State"/>
<field name="state" select="1"/>
<group col="5" colspan="2">
<button name="action_confirm" states="draft" string="Confirm" type="object" icon="gtk-apply"/>
<button name="action_assign" states="confirmed" string="Set Available" type="object" icon="gtk-yes"/>
<button name="action_cancel" states="assigned,confirmed" string="Cancel" type="object" icon="gtk-cancel"/>
<button name="%(partial_move)d" states="assigned" string="Partial" type="action" icon="gtk-justify-fill"/>
<button name="action_done" states="assigned" string="Done" type="object" icon="gtk-jump-to"/>
</group>
</page>
<page string="Return Packing History">
<field name="move_stock_return_history" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record id="view_move_search_reception_picking" model="ir.ui.view">
<record id="view_move_search_reception_picking" model="ir.ui.view">
<field name="name">stock.move.search2</field>
<field name="model">stock.move</field>
<field name="type">search</field>
@ -1307,19 +1378,32 @@
</group>
</search>
</field>
</record>
</record>
<record id="action_reception_picking_move" model="ir.actions.act_window">
<field name="name">Incoming Products</field>
<record id="action_reception_picking_move" model="ir.actions.act_window">
<field name="name">Reception Picking Stock Move</field>
<field name="res_model">stock.move</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('picking_id.type','=','in')]</field>
<field name="domain">[('picking_id','!=',False),('picking_id.type','=','in')]</field>
<field name="view_id" ref="view_move_tree_reception_picking"/>
<field name="search_view_id" ref="view_move_search_reception_picking"/>
</record>
<!-- <menuitem action="action_reception_picking_move" id="menu_action_reception_picking_move" parent="menu_stock_root"/>-->
<record model="ir.actions.act_window.view" id="action_move_reception_picking_tree">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_move_tree_reception_picking"/>
<field name="act_window_id" ref="action_reception_picking_move"/>
</record>
<record model="ir.actions.act_window.view" id="action_move_reception_picking_form">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="view_move_form_reception_picking"/>
<field name="act_window_id" ref="action_reception_picking_move"/>
</record>
<menuitem action="action_reception_picking_move" id="menu_action_reception_picking_move" parent="menu_stock_warehouse_mgmt" sequence="4"/>
# -------------------------------------------------------------