diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index e43b91a97b0..8bcb50d27a9 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() diff --git a/bin/service/web_services.py b/bin/service/web_services.py index 10a11a4819f..b8b5a8e1bee 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')