[FIX] sale_stock,purchase: review help string + remove incorrect fallback to local TZ
See also http://bugs.python.org/issue7229 bzr revid: odo@openerp.com-20130404092134-0zt7blbl1kt3p0lz
This commit is contained in:
parent
ff481fab60
commit
ef84d5c421
|
@ -24,9 +24,12 @@ from openerp.osv import osv,fields
|
||||||
class company(osv.osv):
|
class company(osv.osv):
|
||||||
_inherit = 'res.company'
|
_inherit = 'res.company'
|
||||||
_columns = {
|
_columns = {
|
||||||
'po_lead': fields.float('Purchase Lead Time', required=True,
|
'po_lead': fields.float(
|
||||||
help="This is the leads/security time for each purchase order. For company security purpose this"\
|
'Purchase Lead Time', required=True,
|
||||||
"many days will be removed from the date what suppliers has promised to you."),
|
help="Margin of error for supplier lead times. When the system"\
|
||||||
|
"generates Purchase Orders for procuring products,"\
|
||||||
|
"they will be scheduled that many days earlier "\
|
||||||
|
"to cope with unexpected supplier delays."),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'po_lead': lambda *a: 1.0,
|
'po_lead': lambda *a: 1.0,
|
||||||
|
|
|
@ -596,27 +596,26 @@ class purchase_order(osv.osv):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def date_to_datetime(self, cr, uid, userdate, context=None):
|
def date_to_datetime(self, cr, uid, userdate, context=None):
|
||||||
|
""" Convert date values expressed in user's timezone to
|
||||||
|
server-side UTC timestamp, assuming a default arbitrary
|
||||||
|
time of 12:00 AM - because a time is needed.
|
||||||
|
|
||||||
|
:param str userdate: date string in in user time zone
|
||||||
|
:return: UTC datetime string for server-side use
|
||||||
"""
|
"""
|
||||||
Function accepts date string assumed in client TZ and result is produced
|
# TODO: move to fields.datetime in server after 7.0
|
||||||
in UTC timezone with 12:00 is assumed time to be sure, that system will
|
|
||||||
avoid tz date converstion issues.
|
|
||||||
e.g. Date 2013-03-26 in user tz will get 12:00 Hours and will then
|
|
||||||
get converted to UTC to avoid tz converstion.
|
|
||||||
userdate: date string in in user time zone.
|
|
||||||
return : the utc datetime string.
|
|
||||||
"""
|
|
||||||
user_datetime = datetime.strptime(userdate, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(hours=12.0)
|
user_datetime = datetime.strptime(userdate, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(hours=12.0)
|
||||||
if context and context.get('tz'):
|
if context and context.get('tz'):
|
||||||
tz_name = context['tz']
|
tz_name = context['tz']
|
||||||
else:
|
else:
|
||||||
tz_name = self.pool.get('res.users').read(cr, SUPERUSER_ID, uid, ['tz'])['tz']
|
tz_name = self.pool.get('res.users').read(cr, SUPERUSER_ID, uid, ['tz'])['tz']
|
||||||
if not tz_name:
|
if tz_name:
|
||||||
tz_name = time.tzname[time.daylight]
|
utc = pytz.timezone('UTC')
|
||||||
utc = pytz.timezone('UTC')
|
context_tz = pytz.timezone(tz_name)
|
||||||
context_tz = pytz.timezone(tz_name)
|
local_timestamp = context_tz.localize(user_datetime, is_dst=False)
|
||||||
local_timestamp = context_tz.localize(user_datetime, is_dst=False)
|
user_datetime = local_timestamp.astimezone(utc)
|
||||||
user_datetime = local_timestamp.astimezone(utc)
|
return user_datetime.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||||
return user_datetime.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
return userdate
|
||||||
|
|
||||||
def _prepare_order_picking(self, cr, uid, order, context=None):
|
def _prepare_order_picking(self, cr, uid, order, context=None):
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -24,9 +24,12 @@ from openerp.osv import fields, osv
|
||||||
class company(osv.osv):
|
class company(osv.osv):
|
||||||
_inherit = 'res.company'
|
_inherit = 'res.company'
|
||||||
_columns = {
|
_columns = {
|
||||||
'security_lead': fields.float('Security Days', required=True,
|
'security_lead': fields.float(
|
||||||
help="For company security purpose this many days will be removed from the date, what you have promised to customers,"\
|
'Security Days', required=True,
|
||||||
"to cope up with any problems of procurement, final shipping, order negotiation etc."),
|
help="Margin of error for dates promised to customers. "\
|
||||||
|
"Products will be scheduled for procurement and delivery "\
|
||||||
|
"that many days earlier than the actual promised date, to "\
|
||||||
|
"cope with unexpected delays in the supply chain."),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'security_lead': 0.0,
|
'security_lead': 0.0,
|
||||||
|
|
|
@ -236,27 +236,26 @@ class sale_order(osv.osv):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def date_to_datetime(self, cr, uid, userdate, context=None):
|
def date_to_datetime(self, cr, uid, userdate, context=None):
|
||||||
|
""" Convert date values expressed in user's timezone to
|
||||||
|
server-side UTC timestamp, assuming a default arbitrary
|
||||||
|
time of 12:00 AM - because a time is needed.
|
||||||
|
|
||||||
|
:param str userdate: date string in in user time zone
|
||||||
|
:return: UTC datetime string for server-side use
|
||||||
"""
|
"""
|
||||||
Function accepts date string assumed in client TZ and result is produced
|
# TODO: move to fields.datetime in server after 7.0
|
||||||
in UTC timezone with 12:00 is assumed time to be sure, that system will
|
|
||||||
avoid tz date converstion issues.
|
|
||||||
e.g. Date 2013-03-26 in user tz will get 12:00 Hours and will then
|
|
||||||
get converted to UTC to avoid tz converstion.
|
|
||||||
userdate: date string in in user time zone.
|
|
||||||
return : the utc datetime string.
|
|
||||||
"""
|
|
||||||
user_datetime = datetime.strptime(userdate, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(hours=12.0)
|
user_datetime = datetime.strptime(userdate, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(hours=12.0)
|
||||||
if context and context.get('tz'):
|
if context and context.get('tz'):
|
||||||
tz_name = context['tz']
|
tz_name = context['tz']
|
||||||
else:
|
else:
|
||||||
tz_name = self.pool.get('res.users').read(cr, SUPERUSER_ID, uid, ['tz'])['tz']
|
tz_name = self.pool.get('res.users').read(cr, SUPERUSER_ID, uid, ['tz'])['tz']
|
||||||
if not tz_name:
|
if tz_name:
|
||||||
tz_name = time.tzname[time.daylight]
|
utc = pytz.timezone('UTC')
|
||||||
utc = pytz.timezone('UTC')
|
context_tz = pytz.timezone(tz_name)
|
||||||
context_tz = pytz.timezone(tz_name)
|
local_timestamp = context_tz.localize(user_datetime, is_dst=False)
|
||||||
local_timestamp = context_tz.localize(user_datetime, is_dst=False)
|
user_datetime = local_timestamp.astimezone(utc)
|
||||||
user_datetime = local_timestamp.astimezone(utc)
|
return user_datetime.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||||
return user_datetime.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
return userdate
|
||||||
|
|
||||||
# if mode == 'finished':
|
# if mode == 'finished':
|
||||||
# returns True if all lines are done, False otherwise
|
# returns True if all lines are done, False otherwise
|
||||||
|
|
Loading…
Reference in New Issue