From 6acc5a157dc287adde7d31978e2ecc163a3ef9ef Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 15 Nov 2011 17:38:43 +0100 Subject: [PATCH 001/115] [IMP] Moved the tests directory inside the openerp module, added --run-tests command-line argument. bzr revid: vmt@openerp.com-20111115163843-djq6hybp24lk9f5e --- openerp-server | 14 +++++++++++ openerp/addons/base/test/test_ir_cron.py | 12 +++++----- openerp/tests/__init__.py | 17 +++++++++++++ .../tests}/addons/test_exceptions/__init__.py | 0 .../addons/test_exceptions/__openerp__.py | 0 .../tests}/addons/test_exceptions/models.py | 0 .../tests}/addons/test_exceptions/view.xml | 0 {tests => openerp/tests}/common.py | 24 ++++++++++--------- {tests => openerp/tests}/test_ir_sequence.py | 4 +++- {tests => openerp/tests}/test_orm.py | 8 +++---- {tests => openerp/tests}/test_xmlrpc.py | 5 +++- openerp/tools/config.py | 5 ++++ tests/__init__.py | 2 -- 13 files changed, 66 insertions(+), 25 deletions(-) create mode 100644 openerp/tests/__init__.py rename {tests => openerp/tests}/addons/test_exceptions/__init__.py (100%) rename {tests => openerp/tests}/addons/test_exceptions/__openerp__.py (100%) rename {tests => openerp/tests}/addons/test_exceptions/models.py (100%) rename {tests => openerp/tests}/addons/test_exceptions/view.xml (100%) rename {tests => openerp/tests}/common.py (84%) rename {tests => openerp/tests}/test_ir_sequence.py (99%) rename {tests => openerp/tests}/test_orm.py (97%) rename {tests => openerp/tests}/test_xmlrpc.py (96%) delete mode 100644 tests/__init__.py diff --git a/openerp-server b/openerp-server index 71a52d5f06b..c108d9f9372 100755 --- a/openerp-server +++ b/openerp-server @@ -221,6 +221,20 @@ if __name__ == "__main__": setup_signal_handlers() + if config["run_tests_no_db"]: + import unittest2 + import openerp.tests + # This test suite creates a database. + unittest2.TextTestRunner(verbosity=2).run(openerp.tests.make_suite_no_db()) + sys.exit(0) + + if config["run_tests"]: + import unittest2 + import openerp.tests + # This test suite assumes a database. + unittest2.TextTestRunner(verbosity=2).run(openerp.tests.make_suite()) + sys.exit(0) + if config["test_file"]: run_test_file(config['db_name'], config['test_file']) sys.exit(0) diff --git a/openerp/addons/base/test/test_ir_cron.py b/openerp/addons/base/test/test_ir_cron.py index 6ef79ac3a78..2154c014f8c 100644 --- a/openerp/addons/base/test/test_ir_cron.py +++ b/openerp/addons/base/test/test_ir_cron.py @@ -40,7 +40,7 @@ JOB = { 'model': u'ir.cron' } -class test_ir_cron(openerp.osv.osv.osv): +class x_test_ir_cron(openerp.osv.osv.osv): """ Add a few handy methods to test cron jobs scheduling. """ _inherit = "ir.cron" @@ -57,7 +57,7 @@ class test_ir_cron(openerp.osv.osv.osv): time.sleep(80) print ">>> out _80_seconds" - def test_0(self, cr, uid): + def x_test_0(self, cr, uid): now = datetime.now() t1 = (now + relativedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:%S') t2 = (now + relativedelta(minutes=1, seconds=5)).strftime('%Y-%m-%d %H:%M:%S') @@ -66,17 +66,17 @@ class test_ir_cron(openerp.osv.osv.osv): self.create(cr, uid, dict(JOB, name='test_0 _20_seconds B', function='_20_seconds', nextcall=t2)) self.create(cr, uid, dict(JOB, name='test_0 _20_seconds C', function='_20_seconds', nextcall=t3)) - def test_1(self, cr, uid): + def x_test_1(self, cr, uid): now = datetime.now() t1 = (now + relativedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:%S') self.create(cr, uid, dict(JOB, name='test_1 _20_seconds * 3', function='_20_seconds', nextcall=t1, numbercall=3)) - def test_2(self, cr, uid): + def x_test_2(self, cr, uid): now = datetime.now() t1 = (now + relativedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:%S') self.create(cr, uid, dict(JOB, name='test_2 _80_seconds * 2', function='_80_seconds', nextcall=t1, numbercall=2)) - def test_3(self, cr, uid): + def x_test_3(self, cr, uid): now = datetime.now() t1 = (now + relativedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:%S') t2 = (now + relativedelta(minutes=1, seconds=5)).strftime('%Y-%m-%d %H:%M:%S') @@ -86,7 +86,7 @@ class test_ir_cron(openerp.osv.osv.osv): self.create(cr, uid, dict(JOB, name='test_3 _20_seconds C', function='_20_seconds', nextcall=t3)) # This test assumes 4 cron threads. - def test_00(self, cr, uid): + def x_test_00(self, cr, uid): self.test_00_set = set() now = datetime.now() t1 = (now + relativedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:%S') diff --git a/openerp/tests/__init__.py b/openerp/tests/__init__.py new file mode 100644 index 00000000000..306edcd68ce --- /dev/null +++ b/openerp/tests/__init__.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +import unittest2 + +import test_orm +import test_ir_sequence +import test_xmlrpc + +def make_suite(): + suite = unittest2.TestSuite() + suite.addTests(unittest2.TestLoader().loadTestsFromModule(test_ir_sequence)) + suite.addTests(unittest2.TestLoader().loadTestsFromModule(test_orm)) + return suite + +def make_suite_no_db(): + suite = unittest2.TestSuite() + suite.addTests(unittest2.TestLoader().loadTestsFromModule(test_xmlrpc)) + return suite diff --git a/tests/addons/test_exceptions/__init__.py b/openerp/tests/addons/test_exceptions/__init__.py similarity index 100% rename from tests/addons/test_exceptions/__init__.py rename to openerp/tests/addons/test_exceptions/__init__.py diff --git a/tests/addons/test_exceptions/__openerp__.py b/openerp/tests/addons/test_exceptions/__openerp__.py similarity index 100% rename from tests/addons/test_exceptions/__openerp__.py rename to openerp/tests/addons/test_exceptions/__openerp__.py diff --git a/tests/addons/test_exceptions/models.py b/openerp/tests/addons/test_exceptions/models.py similarity index 100% rename from tests/addons/test_exceptions/models.py rename to openerp/tests/addons/test_exceptions/models.py diff --git a/tests/addons/test_exceptions/view.xml b/openerp/tests/addons/test_exceptions/view.xml similarity index 100% rename from tests/addons/test_exceptions/view.xml rename to openerp/tests/addons/test_exceptions/view.xml diff --git a/tests/common.py b/openerp/tests/common.py similarity index 84% rename from tests/common.py rename to openerp/tests/common.py index 116898dc7ef..618eafb21f7 100644 --- a/tests/common.py +++ b/openerp/tests/common.py @@ -6,9 +6,10 @@ import xmlrpclib import openerp -ADDONS_PATH = os.environ['OPENERP_ADDONS_PATH'] -PORT = int(os.environ['OPENERP_PORT']) -DB = os.environ['OPENERP_DATABASE'] +# The openerp library is supposed already configured. +ADDONS_PATH = openerp.tools.config['addons_path'] +PORT = openerp.tools.config['xmlrpc_port'] +DB = openerp.tools.config['db_name'] HOST = '127.0.0.1' @@ -25,15 +26,19 @@ db_proxy_61 = None model_proxy_61 = None model_uri_61 = None -def setUpModule(): +def start_openerp(): """ - Start the OpenERP server similary to the openerp-server script and - setup some xmlrpclib proxies. + Start the OpenERP server similary to the openerp-server script. """ - openerp.tools.config['addons_path'] = ADDONS_PATH - openerp.tools.config['xmlrpc_port'] = PORT openerp.service.start_services() + # Ugly way to ensure the server is listening. + time.sleep(2) + +def create_xmlrpc_proxies(): + """ + setup some xmlrpclib proxies. + """ global common_proxy_60 global db_proxy_60 global object_proxy_60 @@ -55,9 +60,6 @@ def setUpModule(): db_proxy_61 = xmlrpclib.ServerProxy(model_uri_61 + 'db') model_proxy_61 = xmlrpclib.ServerProxy(model_uri_61 + 'model/' + DB) - # Ugly way to ensure the server is listening. - time.sleep(2) - def tearDownModule(): """ Shutdown the OpenERP server similarly to a single ctrl-c. """ openerp.service.stop_services() diff --git a/tests/test_ir_sequence.py b/openerp/tests/test_ir_sequence.py similarity index 99% rename from tests/test_ir_sequence.py rename to openerp/tests/test_ir_sequence.py index 8a4731d524f..3bf84cf3404 100644 --- a/tests/test_ir_sequence.py +++ b/openerp/tests/test_ir_sequence.py @@ -19,7 +19,9 @@ import common DB = common.DB ADMIN_USER_ID = common.ADMIN_USER_ID -setUpModule = common.setUpModule +def setUpModule(): + common.create_xmlrpc_proxies() + tearDownModule = common.tearDownModule def registry(model): diff --git a/tests/test_orm.py b/openerp/tests/test_orm.py similarity index 97% rename from tests/test_orm.py rename to openerp/tests/test_orm.py index 61b574df5eb..79ac421b7ac 100644 --- a/tests/test_orm.py +++ b/openerp/tests/test_orm.py @@ -1,9 +1,10 @@ import os import unittest2 + import openerp UID = 1 -DB = os.environ['OPENERP_DATABASE'] +DB = openerp.tools.config['db_name'] CREATE = lambda values: (0, False, values) UPDATE = lambda id, values: (1, id, values) @@ -13,14 +14,13 @@ LINK_TO = lambda id: (4, id, False) DELETE_ALL = lambda: (5, False, False) REPLACE_WITH = lambda ids: (6, False, ids) -def setUpModule(): - openerp.tools.config['addons_path'] = os.environ['OPENERP_ADDONS_PATH'] - class TestO2MSerialization(unittest2.TestCase): + def setUp(self): self.cr = openerp.modules.registry.RegistryManager.get(DB).db.cursor() self.partner = openerp.modules.registry.RegistryManager.get(DB)['res.partner'] self.address = openerp.modules.registry.RegistryManager.get(DB)['res.partner.address'] + def tearDown(self): self.cr.rollback() self.cr.close() diff --git a/tests/test_xmlrpc.py b/openerp/tests/test_xmlrpc.py similarity index 96% rename from tests/test_xmlrpc.py rename to openerp/tests/test_xmlrpc.py index 4ad530cbeda..a08987cdd85 100644 --- a/tests/test_xmlrpc.py +++ b/openerp/tests/test_xmlrpc.py @@ -19,7 +19,10 @@ ADMIN_USER = common.ADMIN_USER ADMIN_USER_ID = common.ADMIN_USER_ID ADMIN_PASSWORD = common.ADMIN_PASSWORD -setUpModule = common.setUpModule +def setUpModule(): + common.start_openerp() + common.create_xmlrpc_proxies() + tearDownModule = common.tearDownModule class test_xmlrpc(unittest2.TestCase): diff --git a/openerp/tools/config.py b/openerp/tools/config.py index f1c3931e81f..2b27844ceed 100644 --- a/openerp/tools/config.py +++ b/openerp/tools/config.py @@ -266,6 +266,10 @@ class configmanager(object): type="int") group.add_option("--unaccent", dest="unaccent", my_default=False, action="store_true", help="Use the unaccent function provided by the database when available.") + group.add_option("--run-tests", dest="run_tests", my_default=False, action="store_true", + help="Run a test suite.") + group.add_option("--run-tests-no-db", dest="run_tests_no_db", my_default=False, action="store_true", + help="Run a test suite (which does'nt assume an existing database).") parser.add_option_group(group) @@ -370,6 +374,7 @@ class configmanager(object): 'list_db', 'xmlrpcs', 'test_file', 'test_disable', 'test_commit', 'test_report_directory', 'osv_memory_count_limit', 'osv_memory_age_limit', 'max_cron_threads', 'unaccent', + 'run_tests', 'run_tests_no_db', ] for arg in keys: diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index 396284efaf7..00000000000 --- a/tests/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -import test_xmlrpc From 9e225c7c1e599624d419cd87f1705ad9a8dcb162 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Wed, 16 Nov 2011 13:11:42 +0100 Subject: [PATCH 002/115] [IMP] check the -d option is also provided when using --run-tests. bzr revid: vmt@openerp.com-20111116121142-bxahffcr7diseoiy --- openerp/tools/config.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openerp/tools/config.py b/openerp/tools/config.py index 2b27844ceed..7d496d524b1 100644 --- a/openerp/tools/config.py +++ b/openerp/tools/config.py @@ -267,9 +267,9 @@ class configmanager(object): group.add_option("--unaccent", dest="unaccent", my_default=False, action="store_true", help="Use the unaccent function provided by the database when available.") group.add_option("--run-tests", dest="run_tests", my_default=False, action="store_true", - help="Run a test suite.") + help="Run a test suite. This creates a database (possibly created with --run-tests-no-db).") group.add_option("--run-tests-no-db", dest="run_tests_no_db", my_default=False, action="store_true", - help="Run a test suite (which does'nt assume an existing database).") + help="Run a test suite (which doesn't assume an existing database).") parser.add_option_group(group) @@ -327,6 +327,10 @@ class configmanager(object): "The config file '%s' selected with -c/--config doesn't exist, "\ "use -s/--save if you want to generate it"%(opt.config)) + die((opt.run_tests or opt.run_tests_no_db) and not opt.db_name, + "The --run-tests and --run-tests-no-db need a database name "\ + "(using the --database or -d options).") + # place/search the config file on Win32 near the server installation # (../etc from the server) # if the server is run by an unprivileged user, he has to specify location of a config file where he has the rights to write, From 330316672ff5490602a1eb4e7743514355c306e4 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 17 Nov 2011 11:06:08 +0100 Subject: [PATCH 003/115] [IMP] Clearer use of update_module arg. - update_module was defined as config[init] or config[update] - this means it is a mutable dictionary - the code testing update_module is actually mutating config[init] and config[update]... - now update_module is really a True or False value. bzr revid: vmt@openerp.com-20111117100608-0n8o99slgk42kiiv --- openerp-server | 6 ++++-- openerp/modules/loading.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openerp-server b/openerp-server index c108d9f9372..e47a8ea29cf 100755 --- a/openerp-server +++ b/openerp-server @@ -89,7 +89,8 @@ def setup_pid_file(): def preload_registry(dbname): """ Preload a registry, and start the cron.""" try: - db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=config['init'] or config['update'], pooljobs=False) + update_module = True if config['init'] or config['update'] else False + db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=update_module, pooljobs=False) # jobs will start to be processed later, when openerp.cron.start_master_thread() is called by openerp.service.start_services() registry.schedule_cron_jobs() @@ -99,7 +100,8 @@ def preload_registry(dbname): def run_test_file(dbname, test_file): """ Preload a registry, possibly run a test file, and start the cron.""" try: - db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=config['init'] or config['update'], pooljobs=False) + update_module = True if config['init'] or config['update'] else False + db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=update_module, pooljobs=False) cr = db.cursor() logger = logging.getLogger('server') logger.info('loading test file %s', test_file) diff --git a/openerp/modules/loading.py b/openerp/modules/loading.py index 00948bc690e..6a2e653fd57 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -276,6 +276,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): tools.config['update']['all'] = 1 if not tools.config['without_demo']: tools.config["demo"]['all'] = 1 + update_module = True # This is a brand new pool, just created in pooler.get_db_and_pool() pool = pooler.get_pool(cr.dbname) @@ -293,7 +294,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): # processed_modules: for cleanup step after install # loaded_modules: to avoid double loading - loaded_modules, processed_modules = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report) + loaded_modules, processed_modules = load_module_graph(cr, graph, status, report=report) if tools.config['load_language']: for lang in tools.config['load_language'].split(','): From 99f99b6d8317ddeb53339b24934d722c97d1dc61 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 17 Nov 2011 15:46:28 +0100 Subject: [PATCH 004/115] [REF] openerp.modules.loading: preparing to support the -i=all option: getting almost rid of the mess with tools.config[init|update]. bzr revid: vmt@openerp.com-20111117144628-pjpac87b5whg5cl0 --- openerp/modules/graph.py | 10 ------- openerp/modules/loading.py | 53 ++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 38 deletions(-) diff --git a/openerp/modules/graph.py b/openerp/modules/graph.py index 7b302e99f4c..62b706ad846 100644 --- a/openerp/modules/graph.py +++ b/openerp/modules/graph.py @@ -122,9 +122,6 @@ class Graph(dict): current.remove(package) node = self.add_node(package, info) node.data = info - for kind in ('init', 'demo', 'update'): - if package in tools.config[kind] or 'all' in tools.config[kind] or kind in force: - setattr(node, kind, True) else: later.add(package) packages.append((package, info)) @@ -186,18 +183,11 @@ class Node(Singleton): node.depth = self.depth + 1 if node not in self.children: self.children.append(node) - for attr in ('init', 'update', 'demo'): - if hasattr(self, attr): - setattr(node, attr, True) self.children.sort(lambda x, y: cmp(x.name, y.name)) return node def __setattr__(self, name, value): super(Singleton, self).__setattr__(name, value) - if name in ('init', 'update', 'demo'): - tools.config[name][self.name] = 1 - for child in self.children: - setattr(child, name, value) if name == 'depth': for child in self.children: setattr(child, name, value + 1) diff --git a/openerp/modules/loading.py b/openerp/modules/loading.py index 6a2e653fd57..551947cf4a4 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -164,7 +164,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= register_module_classes(package.name) models = pool.load(cr, package) loaded_modules.append(package.name) - if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'): + if package.state in ('to install', 'to upgrade'): init_module_models(cr, package.name, models) status['progress'] = float(index) / len(graph) @@ -178,18 +178,19 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= idref = {} - mode = 'update' - if hasattr(package, 'init') or package.state == 'to install': + if package.state == 'to install': mode = 'init' + else: + mode = 'update' - if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'): + if package.state in ('to install', 'to upgrade'): if package.state=='to upgrade': # upgrading the module information modobj.write(cr, 1, [module_id], modobj.get_values_from_terp(package.data)) load_init_xml(module_name, idref, mode) load_update_xml(module_name, idref, mode) load_data(module_name, idref, mode) - if hasattr(package, 'demo') or (package.dbdemo and package.state != 'installed'): + if package.dbdemo and package.state != 'installed': status['progress'] = (index + 0.75) / len(graph) load_demo_xml(module_name, idref, mode) load_demo(module_name, idref, mode) @@ -212,9 +213,6 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= modobj.update_translations(cr, 1, [module_id], None) package.state = 'installed' - for kind in ('init', 'demo', 'update'): - if hasattr(package, kind): - delattr(package, kind) cr.commit() @@ -272,10 +270,6 @@ def load_modules(db, force_demo=False, status=None, update_module=False): if not openerp.modules.db.is_initialized(cr): logger.notifyChannel("init", netsvc.LOG_INFO, "init db") openerp.modules.db.initialize(cr) - tools.config["init"]["all"] = 1 - tools.config['update']['all'] = 1 - if not tools.config['without_demo']: - tools.config["demo"]['all'] = 1 update_module = True # This is a brand new pool, just created in pooler.get_db_and_pool() @@ -294,6 +288,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): # processed_modules: for cleanup step after install # loaded_modules: to avoid double loading + # After load_module_graph(), 'base' has been installed or updated and its state is 'installed'. loaded_modules, processed_modules = load_module_graph(cr, graph, status, report=report) if tools.config['load_language']: @@ -301,28 +296,33 @@ def load_modules(db, force_demo=False, status=None, update_module=False): tools.load_language(cr, lang) # STEP 2: Mark other modules to be loaded/updated + # This is a one-shot use of tools.config[init|update] from the command line + # arguments. It is directly cleared to not interfer with later create/update + # issued via RPC. if update_module: modobj = pool.get('ir.module.module') - if ('base' in tools.config['init']) or ('base' in tools.config['update']): + if ('base' in tools.config['init']) or ('base' in tools.config['update']) \ + or ('all' in tools.config['init']) or ('all' in tools.config['update']): logger.notifyChannel('init', netsvc.LOG_INFO, 'updating modules list') modobj.update_list(cr, 1) + if 'all' in tools.config['init']: + pass + _check_module_names(cr, itertools.chain(tools.config['init'].keys(), tools.config['update'].keys())) - mods = [k for k in tools.config['init'] if tools.config['init'][k]] - if mods: - ids = modobj.search(cr, 1, ['&', ('state', '=', 'uninstalled'), ('name', 'in', mods)]) - if ids: - modobj.button_install(cr, 1, ids) + mods = [k for k in tools.config['init'] if tools.config['init'][k] and k not in ('base', 'all')] + ids = modobj.search(cr, 1, ['&', ('state', '=', 'uninstalled'), ('name', 'in', mods)]) + if ids: + modobj.button_install(cr, 1, ids) # goes from 'uninstalled' to 'to install' - mods = [k for k in tools.config['update'] if tools.config['update'][k]] - if mods: - ids = modobj.search(cr, 1, ['&', ('state', '=', 'installed'), ('name', 'in', mods)]) - if ids: - modobj.button_upgrade(cr, 1, ids) - - cr.execute("update ir_module_module set state=%s where name=%s", ('installed', 'base')) + mods = [k for k in tools.config['update'] if tools.config['update'][k] and k not in ('base', 'all')] + ids = modobj.search(cr, 1, ['&', ('state', '=', 'installed'), ('name', 'in', mods)]) + if ids: + modobj.button_upgrade(cr, 1, ids) # goes from 'installed' to 'to upgrade' + for kind in ('init', 'demo', 'update'): + tools.config[kind] = {} # STEP 3: Load marked modules (skipping base which was done in STEP 1) # IMPORTANT: this is done in two parts, first loading all installed or @@ -372,9 +372,6 @@ def load_modules(db, force_demo=False, status=None, update_module=False): if report.get_report(): logger.notifyChannel('init', netsvc.LOG_INFO, report) - for kind in ('init', 'demo', 'update'): - tools.config[kind] = {} - cr.commit() if update_module: # Remove records referenced from ir_model_data for modules to be From b6b25ea70639bfe2eb5c1249e7b1d40216ab545b Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 17 Nov 2011 16:07:20 +0100 Subject: [PATCH 005/115] [IMP] openerp.modules.loading: -i all seems to work as documented in --help. bzr revid: vmt@openerp.com-20111117150720-uaer043c2k55937n --- openerp/modules/loading.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openerp/modules/loading.py b/openerp/modules/loading.py index 551947cf4a4..d0b18632e31 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -307,7 +307,8 @@ def load_modules(db, force_demo=False, status=None, update_module=False): modobj.update_list(cr, 1) if 'all' in tools.config['init']: - pass + ids = modobj.search(cr, 1, []) + tools.config['init'] = dict.fromkeys([m['name'] for m in modobj.read(cr, 1, ids, ['name'])], 1) _check_module_names(cr, itertools.chain(tools.config['init'].keys(), tools.config['update'].keys())) From e9c405c244249e536f0a97c5b6b9d9b4d7215e06 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 17 Nov 2011 17:28:24 +0100 Subject: [PATCH 006/115] [FIX] openerp.modules.loading: previous change disabled demo data altogether, this should be now fixed by making sure that --withou-demo flag (or its absence) is taken care of, and setting the base module demo field. Normally the demo state of a module should have a ripple effect on all modules depending on it. This might prove not enough in this case and require some more testing. bzr revid: vmt@openerp.com-20111117162824-yqswv6yk7bmiyj4s --- openerp-server | 6 ++++-- openerp/modules/graph.py | 14 +++++++++----- openerp/modules/loading.py | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/openerp-server b/openerp-server index e47a8ea29cf..c985579ef15 100755 --- a/openerp-server +++ b/openerp-server @@ -90,7 +90,8 @@ def preload_registry(dbname): """ Preload a registry, and start the cron.""" try: update_module = True if config['init'] or config['update'] else False - db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=update_module, pooljobs=False) + db, registry = openerp.pooler.get_db_and_pool( + dbname, update_module=update_module, pooljobs=False, force_demo=not config['without_demo']) # jobs will start to be processed later, when openerp.cron.start_master_thread() is called by openerp.service.start_services() registry.schedule_cron_jobs() @@ -101,7 +102,8 @@ def run_test_file(dbname, test_file): """ Preload a registry, possibly run a test file, and start the cron.""" try: update_module = True if config['init'] or config['update'] else False - db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=update_module, pooljobs=False) + db, registry = openerp.pooler.get_db_and_pool( + dbname, update_module=update_module, pooljobs=False, force_demo=not config['without_demo']) cr = db.cursor() logger = logging.getLogger('server') logger.info('loading test file %s', test_file) diff --git a/openerp/modules/graph.py b/openerp/modules/graph.py index 62b706ad846..5c6e5899ce4 100644 --- a/openerp/modules/graph.py +++ b/openerp/modules/graph.py @@ -88,15 +88,19 @@ class Graph(dict): for k, v in additional_data[package.name].items(): setattr(package, k, v) - def add_module(self, cr, module, force=None): - self.add_modules(cr, [module], force) + def add_module(self, cr, module, force_demo=False): + self.add_modules(cr, [module], force_demo) - def add_modules(self, cr, module_list, force=None): - if force is None: - force = [] + def add_modules(self, cr, module_list, force_demo=False): packages = [] len_graph = len(self) for module in module_list: + if force_demo: + cr.execute(""" + UPDATE ir_module_module + SET demo='t' + WHERE name = %s""", + (module,)) # This will raise an exception if no/unreadable descriptor file. # NOTE The call to load_information_from_description_file is already # done by db.initialize, so it is possible to not do it again here. diff --git a/openerp/modules/loading.py b/openerp/modules/loading.py index d0b18632e31..066b78f5e3f 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -281,7 +281,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): # STEP 1: LOAD BASE (must be done before module dependencies can be computed for later steps) graph = openerp.modules.graph.Graph() - graph.add_module(cr, 'base', force) + graph.add_module(cr, 'base', force_demo) if not graph: logger.notifyChannel('init', netsvc.LOG_CRITICAL, 'module base cannot be loaded! (hint: verify addons-path)') raise osv.osv.except_osv(_('Could not load base module'), _('module base cannot be loaded! (hint: verify addons-path)')) From 9212a7f81a4cc1fe74e81cdd4d58523119460a03 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 1 Dec 2011 13:18:56 +0100 Subject: [PATCH 007/115] [FIX] test_ir_cron: the names of the class and methods were changed by mistake. bzr revid: vmt@openerp.com-20111201121856-knw7ewbpj083zf12 --- openerp/addons/base/test/test_ir_cron.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openerp/addons/base/test/test_ir_cron.py b/openerp/addons/base/test/test_ir_cron.py index 2154c014f8c..6ef79ac3a78 100644 --- a/openerp/addons/base/test/test_ir_cron.py +++ b/openerp/addons/base/test/test_ir_cron.py @@ -40,7 +40,7 @@ JOB = { 'model': u'ir.cron' } -class x_test_ir_cron(openerp.osv.osv.osv): +class test_ir_cron(openerp.osv.osv.osv): """ Add a few handy methods to test cron jobs scheduling. """ _inherit = "ir.cron" @@ -57,7 +57,7 @@ class x_test_ir_cron(openerp.osv.osv.osv): time.sleep(80) print ">>> out _80_seconds" - def x_test_0(self, cr, uid): + def test_0(self, cr, uid): now = datetime.now() t1 = (now + relativedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:%S') t2 = (now + relativedelta(minutes=1, seconds=5)).strftime('%Y-%m-%d %H:%M:%S') @@ -66,17 +66,17 @@ class x_test_ir_cron(openerp.osv.osv.osv): self.create(cr, uid, dict(JOB, name='test_0 _20_seconds B', function='_20_seconds', nextcall=t2)) self.create(cr, uid, dict(JOB, name='test_0 _20_seconds C', function='_20_seconds', nextcall=t3)) - def x_test_1(self, cr, uid): + def test_1(self, cr, uid): now = datetime.now() t1 = (now + relativedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:%S') self.create(cr, uid, dict(JOB, name='test_1 _20_seconds * 3', function='_20_seconds', nextcall=t1, numbercall=3)) - def x_test_2(self, cr, uid): + def test_2(self, cr, uid): now = datetime.now() t1 = (now + relativedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:%S') self.create(cr, uid, dict(JOB, name='test_2 _80_seconds * 2', function='_80_seconds', nextcall=t1, numbercall=2)) - def x_test_3(self, cr, uid): + def test_3(self, cr, uid): now = datetime.now() t1 = (now + relativedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:%S') t2 = (now + relativedelta(minutes=1, seconds=5)).strftime('%Y-%m-%d %H:%M:%S') @@ -86,7 +86,7 @@ class x_test_ir_cron(openerp.osv.osv.osv): self.create(cr, uid, dict(JOB, name='test_3 _20_seconds C', function='_20_seconds', nextcall=t3)) # This test assumes 4 cron threads. - def x_test_00(self, cr, uid): + def test_00(self, cr, uid): self.test_00_set = set() now = datetime.now() t1 = (now + relativedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:%S') From 1b54fb39f23f8a6ba0d6e458723b12eb65bbaf94 Mon Sep 17 00:00:00 2001 From: "RGA(OpenERP)" <> Date: Fri, 14 Sep 2012 19:16:04 +0530 Subject: [PATCH 008/115] [FIX] Compute domain fail to eval when domain has array comparision bzr revid: rgaopenerp-20120914134604-agowp1k0lxgutk7s --- addons/web/static/src/js/view_form.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 7d328f012fe..43e5313eb7b 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1527,7 +1527,8 @@ instance.web.form.compute_domain = function(expr, fields) { switch (op.toLowerCase()) { case '=': case '==': - stack.push(field_value == val); + // ([] == []) ==> false + stack.push(_.isEqual(field_value, val)); break; case '!=': case '<>': @@ -1559,6 +1560,7 @@ instance.web.form.compute_domain = function(expr, fields) { op, JSON.stringify(expr)); } } + return _.all(stack, _.identity); }; From f78b41c2ba4d26a89082e82e5585de548dcca4b5 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Wed, 17 Oct 2012 18:30:47 +0530 Subject: [PATCH 009/115] [IMP] Right click on header logo open dialog box to resize logo. bzr revid: bth@tinyerp.com-20121017130047-xw1j2jw9eje8wn8p --- addons/web/static/src/js/chrome.js | 10 +++++++++- addons/web/static/src/xml/base.xml | 19 +++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 67e36678040..bfcb7639a26 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -983,7 +983,15 @@ instance.web.WebClient = instance.web.Client.extend({ start: function() { var self = this; return $.when(this._super()).pipe(function() { - self.$el.on('click', '.oe_logo', function() { + self.$el.on('contextmenu','.oe_logo',function(e) { + instance.web.dialog($(QWeb.render('Resolution')),{ + title: "OpenERP Resolution" }); + $('.resolution a').click(function() { + self.$el.find('.oe_logo').css('width', $(this).text()+"px"); + self.$el.find('.oe_logo img').css('width', $(this).text()+"px"); + }) + }) + self.$el.on('click', '.oe_logo', function(e) { self.action_manager.do_action('home'); }); if (jQuery.param !== undefined && jQuery.deparam(jQuery.param.querystring()).kitten !== undefined) { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index a09897862f6..956d5164729 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -10,6 +10,21 @@ Loading... + +
+ + + + + + + + + + +
100px200px
250px300px
+
+
@@ -404,7 +419,7 @@ - +