From 55b4b2d1d066cd7ac88ed76cf54223499e769573 Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Mon, 13 May 2013 17:45:46 +0200 Subject: [PATCH] [FIX]stock: add method that was added in server here to prevent user to have to update base do not forward in trunk bzr revid: csn@openerp.com-20130513154546-v5zqi6723aeiymxl --- addons/stock/stock.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index fbbee7771b1..bacea01968f 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -29,7 +29,7 @@ from openerp.osv import fields, osv from openerp.tools.translate import _ from openerp import netsvc from openerp import tools -from openerp.tools import float_compare, DEFAULT_SERVER_DATETIME_FORMAT, server_to_local_timestamp_info +from openerp.tools import float_compare, DEFAULT_SERVER_DATETIME_FORMAT, server_to_local_timestamp import openerp.addons.decimal_precision as dp import logging _logger = logging.getLogger(__name__) @@ -2334,6 +2334,31 @@ class stock_move(osv.osv): 'line_id': move_lines, 'ref': move.picking_id and move.picking_id.name}) + #Should be add in server/tools/misc.py in trunk + def server_to_local_timestamp_info(self, str_date, src_format, context=None): + """ + Convert a source timestamp string into a destination timestamp string, attempting to apply the + correct offset if both the server and local timezone are recognized, or no + offset at all if they aren't. + This will return a string representing the date in the timezone of the user with the details of + which timezone is used (for example UTC+0200 (CEST)) + + @param src_date: the str value containing the timestamp in the server timezone. + @param src_format: the format to use when parsing the server timestamp. + @param context: context to be used (should contain the user local timezone) + + @return local/client formatted timestamp, expressed in the local/client timezone if possible + and add information about that timezone. + example: str_date = '2013-03-10 10:35:00' (if server timezone is UTC), if user is in UTC+0200 + return: '2013-03-10 10:35:00 UTC+0200 (CEST)' + """ + if not str_date: + return False + if not context: + context = {} + dst_format = src_format + ' UTC%z (%Z)' + return server_to_local_timestamp(str_date, src_format, dst_format, context.get('tz') or 'UTC') + def action_done(self, cr, uid, ids, context=None): """ Makes the move done and if all moves are done, it will finish the picking. @@ -2361,7 +2386,7 @@ class stock_move(osv.osv): if move.picking_id: picking_ids.append(move.picking_id.id) #add a message in chatter to say that product has been received - user_time = server_to_local_timestamp_info(fields.datetime.now(),context=context) + user_time = self.server_to_local_timestamp_info(fields.datetime.now(), DEFAULT_SERVER_DATETIME_FORMAT, context=context) message = _('Product \'%s\' has been received at \'%s\'') % (move.name, user_time) move.picking_id.message_post(body = message) if move.move_dest_id.id and (move.state != 'done'):