From c9c5f4b7859cb414d37d99f25297f4175c7df74f Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 24 Jan 2013 19:28:08 +0100 Subject: [PATCH 01/27] [FIX] res.config.installer: correct module installing bzr revid: chs@openerp.com-20130124182808-5xvdc0mqst0h2970 --- openerp/addons/base/res/res_config.py | 90 ++++++++++++++++----------- 1 file changed, 54 insertions(+), 36 deletions(-) diff --git a/openerp/addons/base/res/res_config.py b/openerp/addons/base/res/res_config.py index a2368a9f508..4c59180acc3 100644 --- a/openerp/addons/base/res/res_config.py +++ b/openerp/addons/base/res/res_config.py @@ -21,14 +21,47 @@ import logging from operator import attrgetter -import openerp -from openerp import pooler from openerp.osv import osv, fields from openerp.tools import ustr from openerp.tools.translate import _ _logger = logging.getLogger(__name__) + +class res_config_module_installation_mixin(object): + def _install_modules(self, cr, uid, modules, context): + """Install the requested modules. + return the next action to execute + + modules is a list of tuples + (mod_name, browse_record | None) + """ + ir_module = self.pool.get('ir.module.module') + to_install_ids = [] + to_install_missing_names = [] + + for name, module in modules: + if not module: + to_install_missing_names.append(name) + elif module.state == 'uninstalled': + to_install_ids.append(module.id) + + if to_install_ids: + ir_module.button_immediate_install(cr, uid, to_install_ids, context=context) + + if to_install_missing_names: + return { + 'type': 'ir.actions.client', + 'tag': 'apps', + 'params': {'modules': to_install_missing_names}, + } + + config = self.pool.get('res.config').next(cr, uid, [], context=context) or {} + if config.get('type') not in ('ir.actions.act_window_close',): + return config + + return None + class res_config_configurable(osv.osv_memory): ''' Base classes for new-style configuration items @@ -153,7 +186,7 @@ class res_config_configurable(osv.osv_memory): res_config_configurable() -class res_config_installer(osv.osv_memory): +class res_config_installer(osv.osv_memory, res_config_module_installation_mixin): """ New-style configuration base specialized for addons selection and installation. @@ -351,17 +384,18 @@ class res_config_installer(osv.osv_memory): return fields def execute(self, cr, uid, ids, context=None): - modules = self.pool.get('ir.module.module') to_install = list(self.modules_to_install( cr, uid, ids, context=context)) _logger.info('Selecting addons %s to install', to_install) - modules.state_update( - cr, uid, - modules.search(cr, uid, [('name','in',to_install)]), - 'to install', ['uninstalled'], context=context) - cr.commit() - openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname) - new_db, self.pool = pooler.restart_pool(cr.dbname, update_module=True) + + ir_module = self.pool.get('ir.module.module') + modules = [] + for name in to_install: + mod_ids = ir_module.search(cr, uid, [('name', '=', name)]) + record = ir_module.browse(cr, uid, mod_ids[0], context) if mod_ids else None + modules.append((name, record)) + + return self._install_modules(cr, uid, modules, context=context) res_config_installer() @@ -402,8 +436,7 @@ class ir_actions_configuration_wizard(osv.osv_memory): ir_actions_configuration_wizard() - -class res_config_settings(osv.osv_memory): +class res_config_settings(osv.osv_memory, res_config_module_installation_mixin): """ Base configuration wizard for application settings. It provides support for setting default values, assigning groups to employee users, and installing modules. To make such a 'settings' wizard, define a model like:: @@ -527,37 +560,22 @@ class res_config_settings(osv.osv_memory): getattr(self, method)(cr, uid, ids, context) # module fields: install/uninstall the selected modules - to_install_missing_names = [] + to_install = [] to_uninstall_ids = [] - to_install_ids = [] lm = len('module_') for name, module in classified['module']: if config[name]: - if not module: - # missing module, will be provided by apps.openerp.com - to_install_missing_names.append(name[lm:]) - elif module.state == 'uninstalled': - # local module, to be installed - to_install_ids.append(module.id) + to_install.append((name[lm:], module)) else: if module and module.state in ('installed', 'to upgrade'): to_uninstall_ids.append(module.id) if to_uninstall_ids: ir_module.button_immediate_uninstall(cr, uid, to_uninstall_ids, context=context) - if to_install_ids: - ir_module.button_immediate_install(cr, uid, to_install_ids, context=context) - if to_install_missing_names: - return { - 'type': 'ir.actions.client', - 'tag': 'apps', - 'params': {'modules': to_install_missing_names}, - } - - config = self.pool.get('res.config').next(cr, uid, [], context=context) or {} - if config.get('type') not in ('ir.actions.act_window_close',): - return config + action = self._install_modules(cr, uid, to_install, context=context) + if action: + return action # force client-side reload (update user menu and current view) return { @@ -572,17 +590,17 @@ class res_config_settings(osv.osv_memory): if action_ids: return act_window.read(cr, uid, action_ids[0], [], context=context) return {} - + def name_get(self, cr, uid, ids, context=None): """ Override name_get method to return an appropriate configuration wizard name, and not the generated name.""" - + if not ids: return [] # name_get may receive int id instead of an id list if isinstance(ids, (int, long)): ids = [ids] - + act_window = self.pool.get('ir.actions.act_window') action_ids = act_window.search(cr, uid, [('res_model', '=', self._name)], context=context) name = self._name From 4c89124778a1516cd3371347831bb4b6f1e60a74 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 24 Jan 2013 20:00:39 +0100 Subject: [PATCH 02/27] [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 03/27] [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 16289266c99096a1770fd6039539da26a0ce7c0f Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 25 Jan 2013 14:34:53 +0100 Subject: [PATCH 04/27] [FIX] res.config.installer: correct module installing bzr revid: chs@openerp.com-20130125133453-aqu5eotetdyb2zpj --- openerp/addons/base/res/res_config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/res/res_config.py b/openerp/addons/base/res/res_config.py index 4c59180acc3..1ca6fd57cfa 100644 --- a/openerp/addons/base/res/res_config.py +++ b/openerp/addons/base/res/res_config.py @@ -56,10 +56,6 @@ class res_config_module_installation_mixin(object): 'params': {'modules': to_install_missing_names}, } - config = self.pool.get('res.config').next(cr, uid, [], context=context) or {} - if config.get('type') not in ('ir.actions.act_window_close',): - return config - return None class res_config_configurable(osv.osv_memory): @@ -577,6 +573,10 @@ class res_config_settings(osv.osv_memory, res_config_module_installation_mixin): if action: return action + config = self.pool.get('res.config').next(cr, uid, [], context=context) or {} + if config.get('type') not in ('ir.actions.act_window_close',): + return config + # force client-side reload (update user menu and current view) return { 'type': 'ir.actions.client', From e0284cfe90a75ce815ba31d452eef15c676515ca Mon Sep 17 00:00:00 2001 From: "Ravi Gohil (OpenERP)" Date: Fri, 22 Feb 2013 11:57:54 +0530 Subject: [PATCH 05/27] [FIX] Passed context in write(...)(Courtesy: Humberto Arocha(hbto)). (Maintenance Case: 586824) lp bug: https://launchpad.net/bugs/1088086 fixed bzr revid: rgo@tinyerp.com-20130222062754-nbsp6a491xzm63kw --- openerp/addons/base/res/res_company.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py index 022c9c06da0..c8ea8d7856e 100644 --- a/openerp/addons/base/res/res_company.py +++ b/openerp/addons/base/res/res_company.py @@ -97,7 +97,7 @@ class res_company(osv.osv): address_data = part_obj.address_get(cr, uid, [company.partner_id.id], adr_pref=['default']) address = address_data['default'] if address: - part_obj.write(cr, uid, [address], {name: value or False}) + part_obj.write(cr, uid, [address], {name: value or False}, context=context) else: part_obj.create(cr, uid, {name: value or False, 'parent_id': company.partner_id.id}, context=context) return True From 326506db2c5115644eacf43dd266d28b068af338 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 11 Apr 2013 20:22:26 +0200 Subject: [PATCH 06/27] [FIX] mail: mail composer: Use a text field instead of a html field html fields are sanitized just before saving data into the database. In the composer, this cause the sanitization of the templated message (for mass mailing messages) before the rendering, forbidding the use of templated html links. The html of the message is sanitized by message_post() bzr revid: chs@openerp.com-20130411182226-lwnpkh4tmyswjjnc --- addons/mail/wizard/mail_compose_message.py | 1 + addons/mail/wizard/mail_compose_message_view.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 301dff515b3..16cfc99c513 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -116,6 +116,7 @@ class mail_compose_message(osv.TransientModel): 'mail_compose_message_ir_attachments_rel', 'wizard_id', 'attachment_id', 'Attachments'), 'filter_id': fields.many2one('ir.filters', 'Filters'), + 'body': fields.text('Contents'), } _defaults = { diff --git a/addons/mail/wizard/mail_compose_message_view.xml b/addons/mail/wizard/mail_compose_message_view.xml index 00ba33a6d6f..73c16713718 100644 --- a/addons/mail/wizard/mail_compose_message_view.xml +++ b/addons/mail/wizard/mail_compose_message_view.xml @@ -30,7 +30,7 @@ - +