diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 41624b56091..72fe0c68af1 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -272,6 +272,17 @@ def get_modules(): return list(set(listdir(ad) + listdir(_ad))) +def get_modules_with_version(): + modules = get_modules() + res = {} + for module in modules: + terp = get_module_resource(module, '__terp__.py') + try: + info = eval(tools.file_open(terp).read()) + res[module] = "%s.%s" % (release.major_version, info['version']) + except Exception, e: + continue + return res def create_graph(cr, module_list, force=None): graph = Graph() @@ -337,11 +348,11 @@ def init_module_objects(cr, module_name, obj_list): logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: creating or updating database tables' % module_name) todo = [] for obj in obj_list: - if hasattr(obj, 'init'): - obj.init(cr) result = obj._auto_init(cr, {'module': module_name}) if result: todo += result + if hasattr(obj, 'init'): + obj.init(cr) cr.commit() todo.sort() for t in todo: diff --git a/bin/osv/fields.py b/bin/osv/fields.py index 99b39ed9c65..b44579957c4 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -155,12 +155,8 @@ class char(_column): # we need to convert the string to a unicode object to be able # to evaluate its length (and possibly truncate it) reliably - if isinstance(symb, str): - u_symb = unicode(symb, 'utf8') - elif isinstance(symb, unicode): - u_symb = symb - else: - u_symb = unicode(symb) + u_symb = tools.ustr(symb) + return u_symb[:self.size].encode('utf8') diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 6ecb829a852..4431937b924 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1939,7 +1939,7 @@ class orm(orm_template): return "COALESCE(write_date, create_date, now())::timestamp AS %s" % (f,) return "now()::timestamp AS %s" % (f,) if isinstance(self._columns[f], fields.binary) and context.get('bin_size', False): - return "length(%s) as %s" % (f,f) + return 'length("%s") as "%s"' % (f, f) return '"%s"' % (f,) fields_pre2 = map(convert_field, fields_pre) for i in range(0, len(ids), cr.IN_MAX): diff --git a/bin/release.py b/bin/release.py index de5518975d5..5d0e607a544 100644 --- a/bin/release.py +++ b/bin/release.py @@ -23,7 +23,7 @@ name = 'openerp-server' version = '5.0.0' -release = '2' +release = '3' major_version = '5.0' description = 'OpenERP Server' long_desc = '''\ @@ -35,7 +35,7 @@ customizable reports, and XML-RPC interfaces. ''' classifiers = """\ Development Status :: 5 - Production/Stable -License :: OSI Approved :: GNU General Public License Version 3 (GPL-3) +License :: OSI Approved :: GNU General Public License (GPL) Programming Language :: Python """ url = 'http://www.openerp.com' diff --git a/bin/service/web_services.py b/bin/service/web_services.py index 10a11a4819f..fff7491653c 100644 --- a/bin/service/web_services.py +++ b/bin/service/web_services.py @@ -320,6 +320,7 @@ class common(netsvc.Service): self.exportMethod(self.login) self.exportMethod(self.logout) self.exportMethod(self.timezone_get) + self.exportMethod(self.get_available_updates) self.exportMethod(self.get_migration_scripts) def ir_set(self, db, uid, password, keys, args, name, value, replace=True, isobject=False): @@ -385,12 +386,26 @@ GNU Public Licence. def timezone_get(self, db, login, password): return time.tzname[0] + + def get_available_updates(self, password, contract_id, contract_password): + security.check_super(password) + import tools.maintenance as tm + try: + rc = tm.remote_contract(contract_id, contract_password) + if not rc.id: + raise tm.RemoteContractException('This contract does not exist or is not active') + + return rc.get_available_updates(rc.id, addons.get_modules_with_version()) + + except tm.RemoteContractException, e: + self.abortResponse(1, 'Migration Error', 'warning', str(e)) + def get_migration_scripts(self, password, contract_id, contract_password): security.check_super(password) l = netsvc.Logger() + import tools.maintenance as tm try: - import tools.maintenance as tm rc = tm.remote_contract(contract_id, contract_password) if not rc.id: raise tm.RemoteContractException('This contract does not exist or is not active') @@ -399,7 +414,7 @@ GNU Public Licence. l.notifyChannel('migration', netsvc.LOG_INFO, 'starting migration with contract %s' % (rc.name,)) - zips = rc.retrieve_updates(rc.id) + zips = rc.retrieve_updates(rc.id, addons.get_modules_with_version()) from shutil import rmtree, copytree, copy diff --git a/bin/tools/misc.py b/bin/tools/misc.py index e5fe498c84b..8863a8cc2e5 100644 --- a/bin/tools/misc.py +++ b/bin/tools/misc.py @@ -677,11 +677,19 @@ def ustr(value): if not isinstance(value, str): value = str(value) - try: + try: # first try utf-8 return unicode(value, 'utf-8') except: - from locale import getlocale - return unicode(value, getlocale()[1]) + pass + + try: # then extened iso-8858 + return unicode(value, 'iso-8859-15') + except: + pass + + # else use default system locale + from locale import getlocale + return unicode(value, getlocale()[1]) def exception_to_unicode(e): if hasattr(e, 'message'): diff --git a/bin/tools/translate.py b/bin/tools/translate.py index 97c54313436..52036b37ee6 100644 --- a/bin/tools/translate.py +++ b/bin/tools/translate.py @@ -60,7 +60,7 @@ class GettextAlias(object): frame = inspect.stack()[1][0] cr = frame.f_locals.get('cr') try: - lang = frame.f_locals.get('context', {}).get('lang', False) + lang = (frame.f_locals.get('context') or {}).get('lang', False) if not (lang and cr): return source except: @@ -561,7 +561,7 @@ def trans_load_data(db_name, fileobj, fileformat, lang, strict=False, lang_name= fail = True for ln in get_locales(lang): try: - locale.setlocale(locale.LC_ALL, ln) + locale.setlocale(locale.LC_ALL, str(ln)) fail = False break except locale.Error: diff --git a/setup.cfg b/setup.cfg index d3420c25ffb..d8e3b9cd962 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ formats=rpm [bdist_rpm] # release must exactly match 'release' as set in bin/release.py -release=2 +release=3 requires=python >= 2.4 #build-requires=python-devel >= 2.3 diff --git a/setup.py b/setup.py index 38f8f9b2ffc..0d5c71dceb8 100755 --- a/setup.py +++ b/setup.py @@ -173,7 +173,7 @@ setup(name = name, 'openerp-server.tools', 'openerp-server.report', 'openerp-server.report.printscreen', - 'openerp-server.report.pyPdf', + 'openerp-server.report.pyPdf', 'openerp-server.report.render', 'openerp-server.report.render.rml2pdf', 'openerp-server.report.render.rml2html',