From d113f6e684dfa80caed52a5e6cfcaf410df9639f Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Wed, 10 Nov 2010 18:16:54 +0530 Subject: [PATCH 1/3] [REVERT]:commit 2996 to opt fro a better solution bzr revid: nch@tinyerp.com-20101110124654-tdko46c0d4g0uoma --- bin/addons/base/res/res_config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/addons/base/res/res_config.py b/bin/addons/base/res/res_config.py index 8552e608586..5b3b0755f96 100644 --- a/bin/addons/base/res/res_config.py +++ b/bin/addons/base/res/res_config.py @@ -113,8 +113,9 @@ class res_config_configurable(osv.osv_memory): current_user_menu = self.pool.get('res.users')\ .browse(cr, uid, uid).menu_id # return the action associated with the menu - return {'menu_reload':True, 'type': 'object'} - + return self.pool.get(current_user_menu.type)\ + .read(cr, uid, current_user_menu.id) + def start(self, cr, uid, ids, context=None): ids2 = self.pool.get('ir.actions.todo').search(cr, uid, [], context=context) for todo in self.pool.get('ir.actions.todo').browse(cr, uid, ids2, context=context): From f331f33049f4e13832fd21d3afb6d60f800ae7b0 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 10 Nov 2010 16:04:48 +0100 Subject: [PATCH 2/3] [IMP] base: add cron job to autovacuum osv_memory objects bzr revid: chs@openerp.com-20101110150448-chvand3pl617r2rr --- bin/addons/base/ir/__init__.py | 1 + bin/addons/base/ir/ir.xml | 15 +++++++++ bin/addons/base/ir/osv_memory_autovacuum.py | 36 +++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 bin/addons/base/ir/osv_memory_autovacuum.py diff --git a/bin/addons/base/ir/__init__.py b/bin/addons/base/ir/__init__.py index 343b50a6998..145a167fdc2 100644 --- a/bin/addons/base/ir/__init__.py +++ b/bin/addons/base/ir/__init__.py @@ -34,6 +34,7 @@ import ir_exports import workflow import ir_rule import wizard +import osv_memory_autovacuum # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml index cb9b7a6d5bf..e3475faf721 100644 --- a/bin/addons/base/ir/ir.xml +++ b/bin/addons/base/ir/ir.xml @@ -1868,5 +1868,20 @@ + + + + + AutoVacuum osv_memory objects + 30 + minutes + -1 + True + + osv_memory.autovacuum + power_on + () + + diff --git a/bin/addons/base/ir/osv_memory_autovacuum.py b/bin/addons/base/ir/osv_memory_autovacuum.py new file mode 100644 index 00000000000..b2ab938d740 --- /dev/null +++ b/bin/addons/base/ir/osv_memory_autovacuum.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010 OpenERP s.a. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv +from osv.orm import orm_memory + +class osv_memory_autovacuum(osv.osv_memory): + _name = 'osv_memory.autovacuum' + + def power_on(self, cr, uid, context=None): + for model in self.pool.obj_list(): + obj = self.pool.get(model) + if isinstance(obj, orm_memory): + obj.vaccum(cr, uid) + return True + +osv_memory_autovacuum() + From 548d0931f0c533fedaa81ab2128ead490b40088b Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 10 Nov 2010 17:01:04 +0100 Subject: [PATCH 3/3] [IMP] base_setup: add overridable method for company config wizard to decide whether default values are shown bzr revid: odo@openerp.com-20101110160104-nj1raznas0w2jvbm --- addons/base_setup/todo.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/base_setup/todo.py b/addons/base_setup/todo.py index 8f16a491bc7..b30669382a5 100644 --- a/addons/base_setup/todo.py +++ b/addons/base_setup/todo.py @@ -49,12 +49,16 @@ class base_setup_company(osv.osv_memory): def _get_all_countries(self, cr, uid, context=None): return self._get_all(cr, uid, 'res.country', context=context) + def _show_company_data(self, cr, uid, context=None): + # We only want to show the default company data in demo mode, otherwise users tend to forget + # to fill in the real company data in their production databases + return self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'module_meta_information').demo + + def default_get(self, cr, uid, fields_list=None, context=None): """ get default company if any, and the various other fields from the company's fields """ - base_mod = self.pool.get('ir.module.module').search(cr, uid, [('name','ilike','base')]) - base_mod_rec = self.pool.get('ir.module.module').browse(cr, uid, base_mod)[0] defaults = super(base_setup_company, self)\ .default_get(cr, uid, fields_list=fields_list, context=context) companies = self.pool.get('res.company') @@ -63,8 +67,10 @@ class base_setup_company(osv.osv_memory): return defaults company = companies.browse(cr, uid, company_id[0]) defaults['company_id'] = company.id - if not base_mod_rec.demo: + + if not self._show_company_data(cr, uid, context=context): return defaults + defaults['currency'] = company.currency_id.id for field in ['name','logo','rml_header1','rml_footer1','rml_footer2']: defaults[field] = company[field]