diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 9b9112ef351..56e184135e0 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -672,6 +672,18 @@ class stock_picking(osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): if context is None: context = {} + mod_obj = self.pool.get('ir.model.data') + if context.get('default_picking_id', False): + picking_type = self.browse(cr, uid, context['default_picking_id'], context=context).type + if picking_type == 'out': + context.update({'default_type':'out'}) + view_id = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_out_form')[1] + elif picking_type == 'in': + context.update({'default_type':'in'}) + view_id = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_in_form')[1] + elif picking_type == 'internal': + context.update({'default_type':'internal'}) + view_id = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_form')[1] type = context.get('default_type', False) res = super(stock_picking, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) if type: @@ -681,11 +693,11 @@ class stock_picking(osv.osv): if report['report_name'] != 'stock.picking.list': continue if type == 'in': - report['string'] = _('Incoming Shipment') + report['string'] = _('Receipt Slip') elif type == 'internal': - report['string'] = _('Internal Shipment') + report['string'] = _('Picking Slip') elif type == 'out': - report['string'] = _('Delivery Order') + report['string'] = _('Delivery Slip') report['name'] = report['string'] for field in res['fields']: @@ -1559,6 +1571,14 @@ stock_production_lot_revision() # Fields: # location_dest_id is only used for predicting futur stocks # +MOVE_STATE = [ + ('draft', 'Draft'), + ('waiting', 'Waiting Another Move'), + ('confirmed', 'Waiting Availability'), + ('assigned', 'Available'), + ('done', 'Done'), + ('cancel', 'Cancelled') +] class stock_move(osv.osv): def _getSSCC(self, cr, uid, context=None): @@ -1650,7 +1670,7 @@ class stock_move(osv.osv): 'move_history_ids2': fields.many2many('stock.move', 'stock_move_history_ids', 'child_id', 'parent_id', 'Move History (parent moves)'), 'picking_id': fields.many2one('stock.picking', 'Reference', select=True,states={'done': [('readonly', True)]}), 'note': fields.text('Notes'), - 'state': fields.selection([('draft', 'New'), ('waiting', 'Waiting Another Move'), ('confirmed', 'Waiting Availability'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True, + 'state': fields.selection(MOVE_STATE, 'State', readonly=True, select=True, help='When the stock move is created it is in the \'Draft\' state.\n After that, it is set to \'Not Available\' state if the scheduler did not find the products.\n When products are reserved it is set to \'Available\'.\n When the picking is done the state is \'Done\'.\ \nThe state is \'Waiting\' if the move is waiting for another one.'), 'price_unit': fields.float('Unit Price', digits_compute= dp.get_precision('Account'), help="Technical field used to record the product cost set by the user during a picking confirmation (when average price costing method is used)"), @@ -1679,6 +1699,36 @@ class stock_move(osv.osv): 'You try to assign a lot which is not from the same product', ['prodlot_id'])] + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + if context is None: + context = {} + type = context.get('default_picking_type', False) + res = super(stock_move, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) + if type: + for field in res['fields']: + # To update the states label according to the containing shipping type + if field == 'state': + _state = [] + for key, value in MOVE_STATE: + if type == 'in': + if key == 'assigned': + value = _('Ready to Receive') + elif key == 'done': + value = _('Received') + elif type == 'internal': + if key == 'assigned': + value = _('Ready to Transfer') + elif key == 'done': + value = _('Transferred') + elif type == 'out': + if key == 'assigned': + value = _('Ready to Deliver') + elif key == 'done': + value = _('Delivered') + _state.append((key,value)) + res['fields']['state']['selection'] = _state + return res + def _default_location_destination(self, cr, uid, context=None): """ Gets default address of partner for destination location @return: Address id or False diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 20a3da0617c..3133738d3a9 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -990,12 +990,13 @@ -