From 4c89124778a1516cd3371347831bb4b6f1e60a74 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 24 Jan 2013 20:00:39 +0100 Subject: [PATCH 1/3] [IMP] account: installer get list of charts from apps bzr revid: chs@openerp.com-20130124190039-qhcyrnrgpue0rak5 --- addons/account/installer.py | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/addons/account/installer.py b/addons/account/installer.py index d02e7196d4d..aba88975e41 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -23,10 +23,16 @@ import datetime from dateutil.relativedelta import relativedelta import logging from operator import itemgetter -from os.path import join as opj import time +import urllib2 +import urlparse -from openerp import netsvc, tools +try: + import simplejson as json +except ImportError: + import json # noqa + +from openerp.release import serie from openerp.tools.translate import _ from openerp.osv import fields, osv @@ -38,13 +44,28 @@ class account_installer(osv.osv_memory): def _get_charts(self, cr, uid, context=None): modules = self.pool.get('ir.module.module') + + # try get the list on apps server + try: + apps_server = self.pool.get('ir.config_parameter').get_value(cr, uid, 'apps.server', 'https://apps.openerp.com') + + up = urlparse.urlparse(apps_server) + url = '{0.scheme}://{0.netloc}/apps/charts?serie={1}'.format(up, serie) + + j = urllib2.urlopen(url, timeout=3).read() + apps_charts = json.loads(j) + + charts = dict(apps_charts) + except Exception: + charts = dict() + # Looking for the module with the 'Account Charts' category category_name, category_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'module_category_localization_account_charts') ids = modules.search(cr, uid, [('category_id', '=', category_id)], context=context) - charts = list( - sorted(((m.name, m.shortdesc) - for m in modules.browse(cr, uid, ids, context=context)), - key=itemgetter(1))) + if ids: + charts.update((m.name, m.shortdesc) for m in modules.browse(cr, uid, ids, context=context)) + + charts = sorted(charts.items(), key=itemgetter(1)) charts.insert(0, ('configurable', _('Custom'))) return charts From a78531df4393b3850b718865df5b748d696975e5 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 25 Jan 2013 13:11:27 +0100 Subject: [PATCH 2/3] [FIX] account: installer: call right method bzr revid: chs@openerp.com-20130125121127-j7i3rwskqojyp8nm --- addons/account/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/installer.py b/addons/account/installer.py index aba88975e41..995e3986af4 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -47,7 +47,7 @@ class account_installer(osv.osv_memory): # try get the list on apps server try: - apps_server = self.pool.get('ir.config_parameter').get_value(cr, uid, 'apps.server', 'https://apps.openerp.com') + apps_server = self.pool.get('ir.config_parameter').get_param(cr, uid, 'apps.server', 'https://apps.openerp.com') up = urlparse.urlparse(apps_server) url = '{0.scheme}://{0.netloc}/apps/charts?serie={1}'.format(up, serie) From 7177183c59cd194936173c32b893c700d66d97e5 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Fri, 12 Apr 2013 17:44:22 +0200 Subject: [PATCH 3/3] [FIX] account: Remove the has_default_company 'module' from the modules to install. [FIX] account: forward the value of execute, because the client does not receive the right action bzr revid: stw@openerp.com-20130412154422-cpycmlmpsjx39rae --- addons/account/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/installer.py b/addons/account/installer.py index 995e3986af4..7ef1b59dcbd 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -138,7 +138,7 @@ class account_installer(osv.osv_memory): def execute(self, cr, uid, ids, context=None): self.execute_simple(cr, uid, ids, context) - super(account_installer, self).execute(cr, uid, ids, context=context) + return super(account_installer, self).execute(cr, uid, ids, context=context) def execute_simple(self, cr, uid, ids, context=None): if context is None: @@ -171,7 +171,7 @@ class account_installer(osv.osv_memory): chart = self.read(cr, uid, ids, ['charts'], context=context)[0]['charts'] _logger.debug('Installing chart of accounts %s', chart) - return modules | set([chart]) + return (modules | set([chart])) - set(['has_default_company']) account_installer()