From e111336ba6d809ece05bb9c08e1085e2283a70c0 Mon Sep 17 00:00:00 2001 From: Christophe Chauvet Date: Mon, 7 Dec 2009 11:56:45 +0100 Subject: [PATCH 01/68] [IMP] Check if the config file exists (only if -c used, and not -s argument in the same time) bzr revid: christophe.chauvet@syleam.fr-20091207105645-9m8qclwrzfbo5cbh --- bin/tools/config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/tools/config.py b/bin/tools/config.py index 2dd6b1131bf..4c6de0bba3c 100644 --- a/bin/tools/config.py +++ b/bin/tools/config.py @@ -202,6 +202,10 @@ class configmanager(object): die(opt.translate_out and (not opt.db_name), "the i18n-export option cannot be used without the database (-d) option") + # Check if the config file exists (only if -c used, and not -s argument) + die(not opt.save and opt.config and not os.path.exists(opt.config), + "The config file define with (-c) doesn't exists, use (-s) if you want to create it") + # place/search the config file on Win32 near the server installation # (../etc from the server) # if the server is run by an unprivileged user, he has to specify location of a config file where he has the rights to write, From f41e52413326d19db5c7f263b860229f08166913 Mon Sep 17 00:00:00 2001 From: "Cristian Salamea (GnuThink)" <> Date: Sun, 13 Dec 2009 16:16:01 -0200 Subject: [PATCH 02/68] [REF] get rid of the mx.Datetime C dependency, meaning better portability, especially to alternative Python interpreters, better maintainability; implements this blueprint: https://blueprints.launchpad.net/openobject-server/+spec/get-rid-of-mx-datetime-dependency; largely the work of Cristian Salamea (GnuThink) bzr revid: rvalyi@gmail.com-20091213181601-4k4mhtgnv2qynrjo --- bin/addons/base/ir/ir_cron.py | 19 ++++++++++--------- bin/addons/base/res/res_currency.py | 3 --- bin/openerp-server.py | 4 ---- bin/report/printscreen/ps_list.py | 8 ++++---- bin/report/report_sxw.py | 10 +++++----- bin/tools/convert.py | 4 ++-- bin/tools/translate.py | 5 +++-- setup.py | 2 +- 8 files changed, 25 insertions(+), 30 deletions(-) diff --git a/bin/addons/base/ir/ir_cron.py b/bin/addons/base/ir/ir_cron.py index 3966a816f4f..c30abbfffe9 100644 --- a/bin/addons/base/ir/ir_cron.py +++ b/bin/addons/base/ir/ir_cron.py @@ -20,8 +20,9 @@ # ############################################################################## -from mx import DateTime import time +import datetime +from dateutil.relativedelta import * 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.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.datetime.strptime(job['nextcall'], '%Y-%m-%d %H:%M:%S') numbercall = job['numbercall'] ok = False diff --git a/bin/addons/base/res/res_currency.py b/bin/addons/base/res/res_currency.py index 0cd80c141c6..f15566f9075 100644 --- a/bin/addons/base/res/res_currency.py +++ b/bin/addons/base/res/res_currency.py @@ -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={} diff --git a/bin/openerp-server.py b/bin/openerp-server.py index 33b5fef9aeb..f4f8e1e2371 100755 --- a/bin/openerp-server.py +++ b/bin/openerp-server.py @@ -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 #---------------------------------------------------------- diff --git a/bin/report/printscreen/ps_list.py b/bin/report/printscreen/ps_list.py index 2d3ee002633..1496077a2c5 100644 --- a/bin/report/printscreen/ps_list.py +++ b/bin/report/printscreen/ps_list.py @@ -29,7 +29,7 @@ import libxslt import locale import time, os -import mx.DateTime +import datetime class report_printscreen_list(report_int): def __init__(self, name): @@ -178,19 +178,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.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.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.datetime.strptime(line[f], '%Y-%m-%d %H:%M:%S') new_d1 = d1.strftime(format) line[f] = new_d1 diff --git a/bin/report/report_sxw.py b/bin/report/report_sxw.py index f1df81e60bc..987ec9c4b58 100644 --- a/bin/report/report_sxw.py +++ b/bin/report/report_sxw.py @@ -25,7 +25,7 @@ import cStringIO import base64 import copy import locale -import mx.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 hasattr(self,'name') and (self.name): - date = mx.DateTime.strptime(self.name,DT_FORMAT) + date = datetime.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 hasattr(self,'name') and self.name: - 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.datetime(*value.timetuple()[:6]) return date.strftime(date_format) return self.lang_dict['lang_obj'].format('%.' + str(digits) + 'f', value, grouping=grouping, monetary=monetary) diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 36eb1751c93..73b4d453b76 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -87,10 +87,10 @@ def _eval_xml(self,node, pool, cr, uid, idref, context=None): a_eval = node.get('eval','') if len(a_eval): import time - from mx import DateTime + 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) diff --git a/bin/tools/translate.py b/bin/tools/translate.py index 83e90325e70..2b1c7a81946 100644 --- a/bin/tools/translate.py +++ b/bin/tools/translate.py @@ -20,6 +20,8 @@ ############################################################################## import os +import datetime + from os.path import join import fnmatch import csv, re @@ -29,7 +31,6 @@ import ir import netsvc from tools.misc import UpdateableStr import inspect -import mx.DateTime as mxdt import tempfile import tarfile import codecs @@ -279,7 +280,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.datetime.now().isoformat(' '), } ) diff --git a/setup.py b/setup.py index 1c088b3f8f2..ef8eb4bd72b 100755 --- a/setup.py +++ b/setup.py @@ -184,7 +184,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", "pyparsing", + "encodings","wizard","pychart","PIL", "pyparsing", "pydot","asyncore","asynchat", "reportlab", "vobject", "HTMLParser", "select"], "excludes" : ["Tkconstants","Tkinter","tcl"], From 15b965fb6f19abed1edebdf07a59c2efa0ac2fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Mon, 14 Dec 2009 01:10:18 -0200 Subject: [PATCH 03/68] [FIX] correct datetime replacement for mxdt.ISO.strUTC(mxdt.ISO.DateTime.utc()) bzr revid: rvalyi@gmail.com-20091214031018-xxl8l8r9s02jvxva --- bin/tools/translate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/tools/translate.py b/bin/tools/translate.py index 2b1c7a81946..99218a91f70 100644 --- a/bin/tools/translate.py +++ b/bin/tools/translate.py @@ -280,7 +280,7 @@ class TinyPoFile(object): 'version': release.version, 'modules': reduce(lambda s, m: s + "#\t* %s\n" % m, modules, ""), 'bugmail': release.support_email, - 'now': datetime.datetime.now().isoformat(' '), + 'now': datetime.datetime.now().isoformat(' ')[0:-7] + '+0000', } ) From 6e2d1e6b710ec3f518f21310e8cb69ff8745e6b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Mon, 14 Dec 2009 10:23:55 -0200 Subject: [PATCH 04/68] [REF] avoid import * bzr revid: rvalyi@gmail.com-20091214122355-eta5tkktvouxiv6i --- bin/addons/base/ir/ir_cron.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/addons/base/ir/ir_cron.py b/bin/addons/base/ir/ir_cron.py index c30abbfffe9..f841bdbb759 100644 --- a/bin/addons/base/ir/ir_cron.py +++ b/bin/addons/base/ir/ir_cron.py @@ -22,7 +22,7 @@ import time import datetime -from dateutil.relativedelta import * +from dateutil.relativedelta import relativedelta import netsvc import tools import pooler From 1cbec3a6429f49189ec25ef6dcef9407a16cba5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Mon, 14 Dec 2009 13:21:04 -0200 Subject: [PATCH 05/68] [REF] changed coding style from datetime.datime.foo to datetime.foo, changing the import accordingly bzr revid: rvalyi@gmail.com-20091214152104-evcck2uv66bbulnf --- bin/addons/base/ir/ir_cron.py | 6 +++--- bin/report/printscreen/ps_list.py | 8 ++++---- bin/report/report_sxw.py | 6 +++--- bin/tools/convert.py | 2 +- bin/tools/translate.py | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bin/addons/base/ir/ir_cron.py b/bin/addons/base/ir/ir_cron.py index f841bdbb759..dcf76945904 100644 --- a/bin/addons/base/ir/ir_cron.py +++ b/bin/addons/base/ir/ir_cron.py @@ -21,7 +21,7 @@ ############################################################################## import time -import datetime +from datetime import datetime from dateutil.relativedelta import relativedelta import netsvc import tools @@ -101,10 +101,10 @@ class ir_cron(osv.osv, netsvc.Agent): cr = db.cursor() try: if not pool._init: - now = datetime.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.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 diff --git a/bin/report/printscreen/ps_list.py b/bin/report/printscreen/ps_list.py index 1496077a2c5..a131848cfac 100644 --- a/bin/report/printscreen/ps_list.py +++ b/bin/report/printscreen/ps_list.py @@ -29,7 +29,7 @@ import libxslt import locale import time, os -import datetime +from datetime import datetime class report_printscreen_list(report_int): def __init__(self, name): @@ -178,19 +178,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 = datetime.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 = datetime.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 = datetime.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 diff --git a/bin/report/report_sxw.py b/bin/report/report_sxw.py index 987ec9c4b58..fafbf4a9172 100644 --- a/bin/report/report_sxw.py +++ b/bin/report/report_sxw.py @@ -25,7 +25,7 @@ import cStringIO import base64 import copy import locale -import 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 hasattr(self,'name') and (self.name): - date = datetime.datetime.strptime(self.name, DT_FORMAT) + date = datetime.strptime(self.name, DT_FORMAT) return date.strftime(self.lang_obj.date_format) return self.val @@ -266,7 +266,7 @@ class rml_parse(object): except:# sometimes it takes converted values into value, so we dont need conversion. return str(value) else: - date = 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) diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 73b4d453b76..b6ed68f2f11 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -87,7 +87,7 @@ def _eval_xml(self,node, pool, cr, uid, idref, context=None): a_eval = node.get('eval','') if len(a_eval): import time - import datetime + from datetime import datetime idref2 = idref.copy() idref2['time'] = time idref2['DateTime'] = datetime diff --git a/bin/tools/translate.py b/bin/tools/translate.py index 99218a91f70..c4dc1bb0617 100644 --- a/bin/tools/translate.py +++ b/bin/tools/translate.py @@ -20,7 +20,7 @@ ############################################################################## import os -import datetime +from datetime import datetime from os.path import join import fnmatch @@ -280,7 +280,7 @@ class TinyPoFile(object): 'version': release.version, 'modules': reduce(lambda s, m: s + "#\t* %s\n" % m, modules, ""), 'bugmail': release.support_email, - 'now': datetime.datetime.now().isoformat(' ')[0:-7] + '+0000', + 'now': datetime.now().isoformat(' ')[0:-7] + '+0000', } ) From d9fbe66f337167bd30ef454b5d6499813cd8d6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Mon, 14 Dec 2009 13:21:52 -0200 Subject: [PATCH 06/68] [FIX] added datutil pure Python lib dependency bzr revid: rvalyi@gmail.com-20091214152152-3mfngzhagcpl47u6 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ef8eb4bd72b..3d9bbd8154d 100755 --- a/setup.py +++ b/setup.py @@ -184,7 +184,7 @@ options = { "dist_dir": 'dist', "packages": ["lxml", "lxml.builder", "lxml._elementpath", "lxml.etree", "lxml.objectify", "decimal", "xml", "xml.dom", "xml.xpath", - "encodings","wizard","pychart","PIL", "pyparsing", + "encodings","dateutil","wizard","pychart","PIL", "pyparsing", "pydot","asyncore","asynchat", "reportlab", "vobject", "HTMLParser", "select"], "excludes" : ["Tkconstants","Tkinter","tcl"], From b53e15b5768674bbd4f0b16c62d1f8ac2153c7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Fri, 25 Dec 2009 16:03:29 -0200 Subject: [PATCH 07/68] [FIX] translate; Launchpad export: time is now UTC and we use a clean strftime rather than a hacky split/concat, output is exactly the same as mx.Datetime bzr revid: rvalyi@gmail.com-20091225180329-a22s8o5lr5qw4qr2 --- bin/tools/translate.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/tools/translate.py b/bin/tools/translate.py index 3d5bd754f1a..b62dc61f1c6 100644 --- a/bin/tools/translate.py +++ b/bin/tools/translate.py @@ -21,6 +21,7 @@ import os from datetime import datetime +from dateutil.tz import tzutc from os.path import join import fnmatch @@ -280,7 +281,7 @@ class TinyPoFile(object): 'version': release.version, 'modules': reduce(lambda s, m: s + "#\t* %s\n" % m, modules, ""), 'bugmail': release.support_email, - 'now': datetime.now().isoformat(' ')[0:-7] + '+0000', + 'now': datetime.now(tzutc()).strftime('%Y-%m-%d %H:%M:%S%z'), } ) From b86c913db882273670a396c3b4dc4cfe5f4a5202 Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Mon, 1 Feb 2010 14:39:42 +0530 Subject: [PATCH 08/68] [IMP] crm: Changed Convert to Opportunity functionality if state is not Open. bzr revid: uco@tinyerp.co.in-20100201090942-fgoujb6j97vxy0if --- addons/crm/crm_opportunity_view.xml | 5 +++-- addons/crm/wizard/crm_lead_wizard.py | 12 +++++++++++- addons/crm/wizard/crm_opportunity_wizard.py | 4 ++++ addons/crm/wizard/crm_phonecall_wizard.py | 11 ++++++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml index a19eb2f3587..526accf3732 100644 --- a/addons/crm/crm_opportunity_view.xml +++ b/addons/crm/crm_opportunity_view.xml @@ -52,9 +52,10 @@