diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 4e62e10f637..bb5af627ebb 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -536,16 +536,7 @@ class stock_picking(osv.osv): if ('name' not in vals) or (vals.get('name')=='/'): seq_obj_name = 'stock.picking.' + vals['type'] vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name) - type_list = { - 'out':_('Picking List'), - 'in':_('Reception'), - 'internal': _('Internal Picking'), - 'delivery': _('Delivery Order') - } new_id = super(stock_picking, self).create(cr, user, vals, context) - if not vals.get('auto_picking', False): - message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals['name'] or "n/a") + _(" with origin")+" '" + (vals.get('origin') or "n/a") + "' "+ _("is created.") - self.log(cr, user, new_id, message) return new_id _columns = { @@ -626,6 +617,9 @@ class stock_picking(osv.osv): for r in picking.move_lines: if r.state == 'draft': todo.append(r.id) + + self.log_picking(cr, uid, ids, context=context) + todo = self.action_explode(cr, uid, todo, context) if len(todo): self.pool.get('stock.move').action_confirm(cr, uid, todo, context=context) @@ -710,16 +704,8 @@ class stock_picking(osv.osv): """ Changes picking state to assigned. @return: True """ - for pick in self.browse(cr, uid, ids, context=context): - type_list = { - 'out':'Picking List', - 'in':'Reception', - 'internal': 'Internal picking', - 'delivery': 'Delivery order' - } - message = type_list.get(pick.type, _('Document')) + " '" + (pick.name or 'n/a') + "' "+ _("is ready to be processed.") - self.log(cr, uid, id, message) self.write(cr, uid, ids, {'state': 'assigned'}) + self.log_picking(cr, uid, ids, context=context) return True def test_finnished(self, cr, uid, ids): @@ -758,8 +744,7 @@ class stock_picking(osv.osv): ids2 = [move.id for move in pick.move_lines] self.pool.get('stock.move').action_cancel(cr, uid, ids2, context) self.write(cr, uid, ids, {'state': 'cancel', 'invoice_state': 'none'}) - message = _('Picking') + " '" + pick.name + "' "+_("is cancelled") - self.log(cr, uid, id, message) + self.log_picking(cr, uid, ids, context=context) return True # @@ -1190,6 +1175,31 @@ class stock_picking(osv.osv): return res + def log_picking(self, cr, uid, ids, context=None): + """ This function will create log messages for picking. + @param cr: the database cursor + @param uid: the current user's ID for security checks, + @param ids: List of Picking Ids + @param context: A standard dictionary for contextual values + """ + for pick in self.browse(cr, uid, ids, context=context): + type_list = { + 'out':'Picking List', + 'in':'Reception', + 'internal': 'Internal picking', + 'delivery': 'Delivery order' + } + message = type_list.get(pick.type, _('Document')) + " '" + (pick.name or 'n/a') + "' " + state_list = { + 'confirmed': "is scheduled for the '" + datetime.strptime(pick.min_date, '%Y-%m-%d %H:%M:%S').strftime('%Y-%m-%d') + "'.", + 'assigned': 'is ready to process.', + 'cancel': 'is Cancelled.', + 'done': 'is processed.', + } + message += state_list[pick.state] + self.log(cr, uid, pick.id, message) + return True + stock_picking() class stock_production_lot(osv.osv): @@ -1844,8 +1854,6 @@ class stock_move(osv.osv): 'ref': move.picking_id and move.picking_id.name, }) - message = _('Move line') + " '" + move.name + "' "+ _("is processed.") - self.log(cr, uid, move.id, message) # This can be removed #tracking_lot = False #if context: @@ -1865,9 +1873,7 @@ class stock_move(osv.osv): for pick_id in picking_ids: wf_service.trg_write(uid, 'stock.picking', pick_id, cr) - for (id,name) in picking_obj.name_get(cr, uid, picking_ids): - message = _('Document') + " '" + name + "' "+ _("is processed.") - self.log(cr, uid, id, message) + picking_obj.log_picking(cr, uid, picking_ids, context=context) return True def create_account_move(self, cr, uid, move,account_id, account_variation, amount, context=None): @@ -1940,8 +1946,11 @@ class stock_move(osv.osv): new_move = self.copy(cr, uid, move.id, default_val) #self.write(cr, uid, [new_move], {'move_history_ids':[(4,move.id)]}) #TODO : to track scrap moves res += [new_move] - message = _('Product ') + " '" + move.product_id.name + "' "+ _("is scraped with") + " '" + str(move.product_qty) + "' "+ _("quantity.") + product_obj = self.pool.get('product.product') + for (id, name) in product_obj.name_get(cr, uid, [move.product_id.id]): + message = _('Product ') + " '" + name + "' "+ _("is scraped with") + " '" + str(move.product_qty) + "' "+ _("quantity.") self.log(cr, uid, move.id, message) + self.action_done(cr, uid, res) return res @@ -2068,8 +2077,11 @@ class stock_move(osv.osv): } self.write(cr, uid, [move.id], update_val) - message = _('Product ') + " '" + move.product_id.name + "' "+ _("is consumed with") + " '" + str(move.product_qty) + "' "+ _("quantity.") - self.log(cr, uid, move.id, message) + + product_obj = self.pool.get('product.product') + for (id, name) in product_obj.name_get(cr, uid, [move.product_id.id]): + message = _('Product ') + " '" + name + "' "+ _("is consumed with") + " '" + str(move.product_qty) + "' "+ _("quantity.") + self.log(cr, uid, move.id, message) self.action_done(cr, uid, res) return res