Xavier Morel 2010-02-02 08:39:28 +01:00
commit b4f3dcde7e
8 changed files with 47 additions and 53 deletions

View File

@ -20,8 +20,9 @@
#
##############################################################################
from mx import DateTime
import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
import netsvc
import tools
import pooler
@ -31,12 +32,12 @@ def str2tuple(s):
return eval('tuple(%s)' % (s or ''))
_intervalTypes = {
'work_days': lambda interval: DateTime.RelativeDateTime(days=interval),
'days': lambda interval: DateTime.RelativeDateTime(days=interval),
'hours': lambda interval: DateTime.RelativeDateTime(hours=interval),
'weeks': lambda interval: DateTime.RelativeDateTime(days=7*interval),
'months': lambda interval: DateTime.RelativeDateTime(months=interval),
'minutes': lambda interval: DateTime.RelativeDateTime(minutes=interval),
'work_days': lambda interval: relativedelta(days=interval),
'days': lambda interval: relativedelta(days=interval),
'hours': lambda interval: relativedelta(hours=interval),
'weeks': lambda interval: relativedelta(days=7*interval),
'months': lambda interval: relativedelta(months=interval),
'minutes': lambda interval: relativedelta(minutes=interval),
}
class ir_cron(osv.osv, netsvc.Agent):
@ -100,10 +101,10 @@ class ir_cron(osv.osv, netsvc.Agent):
cr = db.cursor()
try:
if not pool._init:
now = DateTime.now()
now = datetime.now()
cr.execute('select * from ir_cron where numbercall<>0 and active and nextcall<=now() order by priority')
for job in cr.dictfetchall():
nextcall = DateTime.strptime(job['nextcall'], '%Y-%m-%d %H:%M:%S')
nextcall = datetime.strptime(job['nextcall'], '%Y-%m-%d %H:%M:%S')
numbercall = job['numbercall']
ok = False

View File

@ -26,9 +26,6 @@ import ir
from tools.misc import currency
from tools.translate import _
import mx.DateTime
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
class res_currency(osv.osv):
def _current_rate(self, cr, uid, ids, name, arg, context={}):
res={}

View File

@ -79,10 +79,6 @@ for name, value in [('addons_path', tools.config['addons_path']),
import time
if sys.platform == 'win32':
import mx.DateTime
mx.DateTime.strptime = lambda x, y: mx.DateTime.mktime(time.strptime(x, y))
#----------------------------------------------------------
# init net service
#----------------------------------------------------------

View File

@ -27,7 +27,7 @@ from report import render
import locale
import time, os
import mx.DateTime
from datetime import datetime
class report_printscreen_list(report_int):
def __init__(self, name):
@ -165,19 +165,19 @@ class report_printscreen_list(report_int):
if fields[f]['type'] == 'date' and line[f]:
format = str(locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y'))
d1= mx.DateTime.strptime(line[f],'%Y-%m-%d')
d1 = datetime.strptime(line[f],'%y-%m-%d')
new_d1 = d1.strftime(format)
line[f] = new_d1
if fields[f]['type'] == 'time' and line[f]:
format = str(locale.nl_langinfo(locale.T_FMT))
d1= mx.DateTime.strptime(line[f],'%H:%M:%S')
d1 = datetime.strptime(line[f], '%H:%M:%S')
new_d1 = d1.strftime(format)
line[f] = new_d1
if fields[f]['type'] == 'datetime' and line[f]:
format = str(locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y'))+' '+str(locale.nl_langinfo(locale.T_FMT))
d1= mx.DateTime.strptime(line[f],'%Y-%m-%d %H:%M:%S')
d1 = datetime.strptime(line[f], '%Y-%m-%d %H:%M:%S')
new_d1 = d1.strftime(format)
line[f] = new_d1

View File

@ -25,7 +25,7 @@ import cStringIO
import base64
import copy
import locale
import mx.DateTime
from datetime import datetime
import os
import re
import time
@ -109,7 +109,7 @@ class _date_format(str, _format):
def __str__(self):
if self.val:
if getattr(self,'name', None):
date = mx.DateTime.strptime(self.name,DT_FORMAT)
date = datetime.strptime(self.name, DT_FORMAT)
return date.strftime(self.lang_obj.date_format)
return self.val
@ -121,7 +121,7 @@ class _dttime_format(str, _format):
def __str__(self):
if self.val:
if getattr(self,'name', None):
datetime = mx.DateTime.strptime(self.name,DHM_FORMAT)
datetime = datetime.strptime(self.name, DHM_FORMAT)
return datetime.strftime(self.lang_obj.date_format+ " " + self.lang_obj.time_format)
return self.val
@ -262,11 +262,11 @@ class rml_parse(object):
if not isinstance(value, time.struct_time):
try:
date = mx.DateTime.strptime(str(value),parse_format)
date = datetime.datetime(str(value), parse_format)
except:# sometimes it takes converted values into value, so we dont need conversion.
return str(value)
else:
date = mx.DateTime.DateTime(*(value.timetuple()[:6]))
date = datetime(*value.timetuple()[:6])
return date.strftime(date_format)
return self.lang_dict['lang_obj'].format('%.' + str(digits) + 'f', value, grouping=grouping, monetary=monetary)

View File

@ -18,25 +18,24 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import re
import cStringIO
from lxml import etree
import osv
import ir
import pooler
import csv
import logging
import os.path
import pickle
import re
import sys
import time
from datetime import datetime
from lxml import etree
import ir
import misc
import netsvc
import osv
import pooler
from config import config
import logging
import sys
import pickle
class ConvertError(Exception):
def __init__(self, doc, orig_excpt):
@ -79,11 +78,9 @@ def _eval_xml(self,node, pool, cr, uid, idref, context=None):
return f_val
a_eval = node.get('eval','')
if a_eval:
import time
from mx import DateTime
idref2 = idref.copy()
idref2['time'] = time
idref2['DateTime'] = DateTime
idref2['DateTime'] = datetime
import release
idref2['version'] = release.major_version
idref2['ref'] = lambda x: self.id_get(cr, False, x)

View File

@ -19,21 +19,24 @@
#
##############################################################################
import os
from os.path import join
import codecs
import csv
import fnmatch
import csv, re
import inspect
import locale
import os
import re
import tarfile
import tempfile
from os.path import join
from datetime import datetime
from lxml import etree
import osv, tools, pooler
import ir
import netsvc
from tools.misc import UpdateableStr
import inspect
import mx.DateTime as mxdt
import tempfile
import tarfile
import codecs
import locale
_LOCALE2WIN32 = {
'af_ZA': 'Afrikaans_South Africa',
@ -283,7 +286,7 @@ class TinyPoFile(object):
'version': release.version,
'modules': reduce(lambda s, m: s + "#\t* %s\n" % m, modules, ""),
'bugmail': release.support_email,
'now': mxdt.ISO.strUTC(mxdt.ISO.DateTime.utc()),
'now': datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')+"+0000",
}
)

View File

@ -53,7 +53,7 @@ py_short_version = '%s.%s' % sys.version_info[:2]
required_modules = [
('lxml', 'lxml module: pythonic libxml2 and libxslt bindings'),
('mako', 'Mako template engine'),
('mx', "egenix's mx library for its extended DateTime module"),
('dateutil', "Extensions to the standard datetime module"),
('psycopg2', 'PostgreSQL module'),
('pychart', 'pychart module'),
('pydot', 'pydot module'),
@ -172,7 +172,7 @@ options = {
"dist_dir": 'dist',
"packages": ["lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
"lxml.objectify", "decimal", "xml", "xml.dom", "xml.xpath",
"encodings","mx.DateTime","wizard","pychart","PIL",
"encodings","dateutil","wizard","pychart","PIL",
"pyparsing", "pydot","asyncore","asynchat", "reportlab",
"vobject", "HTMLParser", "select"],
"excludes" : ["Tkconstants","Tkinter","tcl"],