[IMP] inventory usability + lot management

bzr revid: qdp-launchpad@openerp.com-20130806153601-6ddmz456k9rkgxtw
This commit is contained in:
Quentin (OpenERP) 2013-08-06 17:36:01 +02:00
parent ec67f64121
commit 9bd83022b3
4 changed files with 56 additions and 24 deletions

View File

@ -133,8 +133,21 @@ class stock_quant(osv.osv):
"""
_name = "stock.quant"
_description = "Quants"
def _get_quant_name(self, cr, uid, ids, name, args, context=None):
""" Forms complete name of location from parent location to child location.
@return: Dictionary of values
"""
res = {}
for q in self.browse(cr, uid, ids, context=context):
res[q.id] = q.product_id.code
if q.lot_id:
res[q.id] = q.lot_id.name
res[q.id] += ': '+ str(q.qty) + q.product_id.uom_id.name
return res
_columns = {
'name': fields.char('Identifier'),
'name': fields.function(_get_quant_name, type='char', string='Identifier'),
'product_id': fields.many2one('product.product', 'Product', required=True),
'location_id': fields.many2one('stock.location', 'Location', required=True),
'qty': fields.float('Quantity', required=True, help="Quantity of products in this quant, in the default unit of measure of the product"),
@ -882,6 +895,15 @@ class stock_move(osv.osv):
res[move.id] -= self.pool.get('stock.quant.package')._get_product_total_qty(cr, uid, op.package_id, move.product_id.id, context=context)
return res
def _get_lot_ids(self, cr, uid, ids, field_name, args, context=None):
res = dict.fromkeys(ids, False)
for move in self.browse(cr, uid, ids, context=context):
if move.state == 'done':
res[move.id] = [q.id for q in move.quant_ids]
else:
res[move.id] = [q.id for q in move.reserved_quant_ids]
return res
_columns = {
'name': fields.char('Description', required=True, select=True),
'priority': fields.selection([('0', 'Not urgent'), ('1', 'Urgent')], 'Priority'),
@ -954,6 +976,7 @@ class stock_move(osv.osv):
'propagate': fields.boolean('Propagate cancel and split', help='If checked, when this move is cancelled, cancel the linked move too'),
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type'),
'inventory_id': fields.many2one('stock.inventory', 'Inventory'),
'lot_ids': fields.function(_get_lot_ids, type='many2many', relation='stock.quant', string='Lots'),
}
def copy(self, cr, uid, id, default=None, context=None):

View File

@ -159,10 +159,6 @@
<field name="location_id" ref="stock_location_components"/>
</record>
<function model="stock.inventory" name="action_confirm">
<function eval="[[('id', '=', ref('stock_inventory_0'))]]" model="stock.inventory" name="search"/>
</function>
<function model="stock.inventory" name="action_done">
<function eval="[[('id', '=', ref('stock_inventory_0'))]]" model="stock.inventory" name="search"/>
</function>

View File

@ -48,6 +48,7 @@
-
!record {model: stock.inventory, id: stock_inventory_icecream}:
name: Inventory for icecream
product_id: product_icecream
-
!record {model: stock.inventory.line, id: stock_inventory_line_icecream_lot0}:
product_id: product_icecream

View File

@ -101,42 +101,37 @@
<field name="arch" type="xml">
<form string="Physical Inventory" version="7.0">
<header>
<button name="%(action_view_stock_fill_inventory)d" states="draft" string="Fill Inventory" type="object" class="oe_highlight" groups="stock.group_stock_user"/>
<button name="%(action_view_stock_fill_inventory)d" states="draft" string="Fill Inventory" type="action" class="oe_highlight" groups="stock.group_stock_user"/>
<button name="action_done" states="confirm" string="Validate Inventory" type="object" class="oe_highlight" groups="stock.group_stock_manager"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
<button name="action_cancel_inventory" states="draft,confirm,done" string="Cancel Inventory" type="object"/>
<field name="state" widget="statusbar" statusbar_visible="draft,confirm"/>
</header>
<sheet>
<div class="oe_right oe_button_box">
<button name="action_check" string="Check Inventory Adjustments" states="draft,confirm" type="object" />
</div>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1><field name="name" placeholder="e.g. Annual inventory"/></h1>
</div>
<group>
<group>
<field name="name" placeholder="e.g. Annual inventory"/>
<field name="location_id"/>
<field name="product_id"/>
<field name="lot_id"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</group>
<group>
<field name="date"/>
<field name="partner_id"/>
<field name="package_id"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</group>
</group>
<div class="oe_right oe_button_box">
<button name="action_check" string="Check Inventory Adjustments" states="draft,confirm" type="action" />
</div>
<field name="move_ids" context="{'inventory_id':active_id}" readonly="1" attrs="{'invisible': [('move_ids_exist', '=', False)]}">
<tree string="Inventory Adjustments">
<field name="product_id"/>
<field name="lot_id"/>
<field name="product_uom_qty" on_change="onchange_quantity(product_id, product_uom_qty, product_uom, product_uos)"/>
<field name="product_uom" string="Unit of Measure" groups="product.group_uom"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="state" invisible="True"/>
</tree>
</field>
<field name="line_ids">
<field name="move_ids_exist" invisible="1"/>
<notebook>
<page string="Inventory Details">
<field name="line_ids" string="Inventory Details">
<tree string="Inventory Details" editable="bottom">
<field context="{'location':location_id, 'uom':product_uom_id, 'to_date':parent.date}" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom_id,parent.date)" domain="[('type','=','product')]"/>
<field name="product_qty"/>
@ -147,6 +142,21 @@
<field name="state" invisible="True"/>
</tree>
</field>
</page>
<page string="Inventory Adjustments" attrs="{'invisible': [('move_ids_exist', '=', False)]}">
<field name="move_ids" context="{'inventory_id':active_id}" readonly="1">
<tree string="Inventory Adjustments">
<field name="product_id"/>
<field name="lot_ids" widget="many2many_tags"/>
<field name="product_uom_qty" on_change="onchange_quantity(product_id, product_uom_qty, product_uom, product_uos)"/>
<field name="product_uom" string="Unit of Measure" groups="product.group_uom"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="state" invisible="True"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
@ -1241,13 +1251,15 @@
</a>
</div>
<div class="oe_items_list oe_kanban_ellipsis">
<div t-if="record.count_picking.raw_value &gt; 0">
<div>
<a name="%(action_picking_tree)d" type="action">
<field name="count_picking"/> Ready
</a>
<t t-if="record.count_picking.raw_value &gt; 0">
<a name="%(action_picking_tree)d" type="action">
<field name="weekly_picking" widget="stock_sparkline">Weekly Moves</field>
</a>
</t>
</div>
<div t-if="record.count_picking_waiting.raw_value &gt; 0">
<a name="%(action_picking_tree_waiting)d" type="action">