[FIX]stock: improve stock_picking_type view
bzr revid: csn@openerp.com-20130903080121-xu0zhp555tvk54u7
This commit is contained in:
parent
0bcda6375c
commit
35475907ae
|
@ -2285,13 +2285,6 @@ class product_template(osv.osv):
|
|||
'supply_method': 'buy',
|
||||
}
|
||||
|
||||
class stock_picking_code(osv.osv):
|
||||
_name = "stock.picking.code"
|
||||
_description = "Will group picking types for kanban view"
|
||||
_columns = {
|
||||
'name': fields.char("Picking Type", translate=True),
|
||||
}
|
||||
|
||||
class stock_picking_type(osv.osv):
|
||||
_name = "stock.picking.type"
|
||||
_description = "The picking type determines the picking view"
|
||||
|
@ -2383,17 +2376,56 @@ class stock_picking_type(osv.osv):
|
|||
result[type_id]['latest_picking_waiting'] = cmp(pick.date[:10], time.strftime('%Y-%m-%d'))
|
||||
return result
|
||||
|
||||
def onchange_picking_code(self, cr, uid, ids, picking_code=False):
|
||||
if not picking_code:
|
||||
return False
|
||||
|
||||
obj_data = self.pool.get('ir.model.data')
|
||||
stock_loc = obj_data.get_object_reference(cr, uid, 'stock','stock_location_stock')[1]
|
||||
|
||||
result = {
|
||||
'default_location_src_id': stock_loc,
|
||||
'default_location_dest_id': stock_loc,
|
||||
}
|
||||
if picking_code == 'incoming':
|
||||
result['default_location_src_id'] = obj_data.get_object_reference(cr, uid, 'stock','stock_location_suppliers')[1]
|
||||
return {'value': result}
|
||||
if picking_code == 'outgoing':
|
||||
result['default_location_dest_id'] = obj_data.get_object_reference(cr, uid, 'stock','stock_location_customers')[1]
|
||||
return {'value': result}
|
||||
else:
|
||||
return {'value': result}
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
"""Overides orm name_get method to display 'Warehouse_name: PickingType_name' """
|
||||
if not isinstance(ids, list):
|
||||
ids = [ids]
|
||||
res = []
|
||||
if not ids:
|
||||
return res
|
||||
reads = self.browse(cr, uid, ids, context=context)
|
||||
for record in reads:
|
||||
name = record.warehouse_id.name+': '+record.name
|
||||
res.append((record.id, name))
|
||||
return res
|
||||
|
||||
def _default_warehouse(self, cr, uid, context=None):
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
||||
res = self.pool.get('stock.warehouse').search(cr, uid, [('company_id', '=', user.company_id.id)], limit=1, context=context)
|
||||
return res and res[0] or False
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('name', translate=True, required=True),
|
||||
'pack': fields.boolean('Pack', help='This picking type needs packing interface'),
|
||||
'pack': fields.boolean('Prefill Pack Operations', help='This picking type needs packing interface'),
|
||||
'auto_force_assign': fields.boolean('Automatic Availability', help='This picking type does\'t need to check for the availability in stock'),
|
||||
'color': fields.integer('Color Index'),
|
||||
'delivery': fields.boolean('Print delivery'),
|
||||
'sequence_id': fields.many2one('ir.sequence', 'Sequence', required=True),
|
||||
'default_location_src_id': fields.many2one('stock.location', 'Default Source Location'),
|
||||
'default_location_dest_id': fields.many2one('stock.location', 'Default Destination Location'),
|
||||
'code_id': fields.many2one('stock.picking.code', 'Picking type code', required=True),
|
||||
'code_id': fields.selection([('incoming', 'Suppliers'), ('outgoing', 'Customers'), ('internal', 'Internal')], 'Picking type code', required=True),
|
||||
'return_picking_type_id': fields.many2one('stock.picking.type', 'Picking Type for Returns'),
|
||||
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
|
||||
|
||||
# Statistics for the kanban view
|
||||
'weekly_picking': fields.function(_get_picking_data,
|
||||
|
@ -2422,4 +2454,7 @@ class stock_picking_type(osv.osv):
|
|||
type='string', multi='_get_picking_history'),
|
||||
|
||||
}
|
||||
_defaults = {
|
||||
'warehouse_id': _default_warehouse,
|
||||
}
|
||||
|
||||
|
|
|
@ -77,12 +77,6 @@
|
|||
<field name="location_id" ref="stock_location_company"/>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
Picking types, sequences and codes
|
||||
-->
|
||||
|
||||
<!-- Sequences for picking types -->
|
||||
<record id="seq_picking_type_in" model="ir.sequence">
|
||||
|
@ -106,24 +100,12 @@
|
|||
<field name="company_id" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record id="picking_code_in" model="stock.picking.code">
|
||||
<field name="name">Suppliers</field>
|
||||
</record>
|
||||
|
||||
<record id="picking_code_out" model="stock.picking.code">
|
||||
<field name="name">Customers</field>
|
||||
</record>
|
||||
|
||||
<record id="picking_code_internal" model="stock.picking.code">
|
||||
<field name="name">Internal</field>
|
||||
</record>
|
||||
|
||||
<record id="picking_type_in" model="stock.picking.type">
|
||||
<field name="name">Receptions</field>
|
||||
<field name="sequence_id" ref="seq_picking_type_in"/>
|
||||
<field name="default_location_src_id" ref="stock_location_suppliers"/>
|
||||
<field name="default_location_dest_id" ref="stock_location_stock"/>
|
||||
<field name="code_id" ref="picking_code_in"/>
|
||||
<field name="code_id">incoming</field>
|
||||
<field name="auto_force_assign">True</field>
|
||||
</record>
|
||||
|
||||
|
@ -132,13 +114,13 @@
|
|||
<field name="sequence_id" ref="seq_picking_type_out"/>
|
||||
<field name="default_location_src_id" ref="stock_location_stock"/>
|
||||
<field name="default_location_dest_id" ref="stock_location_customers"/>
|
||||
<field name="code_id" ref="picking_code_out"/>
|
||||
<field name="code_id">outgoing</field>
|
||||
</record>
|
||||
|
||||
<record id="picking_type_internal" model="stock.picking.type">
|
||||
<field name="name">Internal Transfers</field>
|
||||
<field name="sequence_id" ref="seq_picking_type_internal"/>
|
||||
<field name="code_id" ref="picking_code_internal"/>
|
||||
<field name="code_id">internal</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
|
|
@ -1205,18 +1205,27 @@
|
|||
<field name="model">stock.picking.type</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Picking Types" version="7.0">
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="code_id"/>
|
||||
<field name="sequence_id"/>
|
||||
<field name="pack"/>
|
||||
<field name="auto_force_assign"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="default_location_src_id"/>
|
||||
<field name="default_location_dest_id"/>
|
||||
<field name="return_picking_type_id"/>
|
||||
</group>
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="sequence_id"/>
|
||||
<field name="warehouse_id"/>
|
||||
<field name="pack"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="code_id" on_change="onchange_picking_code(code_id)"/>
|
||||
<field name="return_picking_type_id"/>
|
||||
<field name="auto_force_assign"/>
|
||||
<field name="delivery"/>
|
||||
</group>
|
||||
</group>
|
||||
<separator string="Locations"/>
|
||||
<group>
|
||||
<field name="default_location_src_id" attrs="{'required': [('code_id', '=', 'internal')]}"/>
|
||||
<field name="default_location_dest_id" attrs="{'required': [('code_id', 'in', ('internal', 'incoming'))]}"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue