From 001c45160831ea3bb7e735bad82d2d4043cc7b8b Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 29 Nov 2012 15:07:45 +0100 Subject: [PATCH 1/5] [REV] reverted install-all commit (vmt@openerp.com-20121128142106-pdkcruhyz0sjltk8) bzr revid: vmt@openerp.com-20121129140745-wn2o9ek3beuf7y3y --- openerp/cli/server.py | 10 ++---- openerp/modules/graph.py | 24 +++++++++------ openerp/modules/loading.py | 63 +++++++++++++++++++------------------- 3 files changed, 48 insertions(+), 49 deletions(-) diff --git a/openerp/cli/server.py b/openerp/cli/server.py index 9352ad37ef0..f030f801967 100644 --- a/openerp/cli/server.py +++ b/openerp/cli/server.py @@ -94,11 +94,7 @@ def setup_pid_file(): def preload_registry(dbname): """ Preload a registry, and start the cron.""" try: - config = openerp.tools.config - 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, - force_demo=not config['without_demo']) + db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=openerp.tools.config['init'] or openerp.tools.config['update'], 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() @@ -109,9 +105,7 @@ def run_test_file(dbname, test_file): """ Preload a registry, possibly run a test file, and start the cron.""" try: config = openerp.tools.config - 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, force_demo=not config['without_demo']) + db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=config['init'] or config['update'], pooljobs=False) cr = db.cursor() _logger.info('loading test file %s', test_file) openerp.tools.convert_yaml_import(cr, 'base', file(test_file), 'test', {}, 'test', True) diff --git a/openerp/modules/graph.py b/openerp/modules/graph.py index f7e9bc7c77a..56b17e3239a 100644 --- a/openerp/modules/graph.py +++ b/openerp/modules/graph.py @@ -87,19 +87,15 @@ class Graph(dict): for k, v in additional_data[package.name].items(): setattr(package, k, v) - def add_module(self, cr, module, force_demo=False): - self.add_modules(cr, [module], force_demo) + def add_module(self, cr, module, force=None): + self.add_modules(cr, [module], force) - def add_modules(self, cr, module_list, force_demo=False): + def add_modules(self, cr, module_list, force=None): + if force is None: + force = [] 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. @@ -125,6 +121,9 @@ 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,11 +185,18 @@ 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 13b02bd7a6e..bcda1690c91 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -42,7 +42,6 @@ from openerp import SUPERUSER_ID from openerp import SUPERUSER_ID from openerp.tools.translate import _ -from openerp.tools import assertion_report from openerp.modules.module import initialize_sys_path, \ load_openerp_module, init_module_models @@ -158,7 +157,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= models = pool.load(cr, package) loaded_modules.append(package.name) - if package.state in ('to install', 'to upgrade'): + if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'): init_module_models(cr, package.name, models) pool._init_modules.add(package.name) status['progress'] = float(index) / len(graph) @@ -172,19 +171,18 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= idref = {} - if package.state == 'to install': + mode = 'update' + if hasattr(package, 'init') or package.state == 'to install': mode = 'init' - else: - mode = 'update' - if package.state in ('to install', 'to upgrade'): + if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'): if package.state=='to upgrade': # upgrading the module information modobj.write(cr, SUPERUSER_ID, [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 package.dbdemo and package.state != 'installed': + if hasattr(package, 'demo') or (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) @@ -214,6 +212,9 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= modobj.update_translations(cr, SUPERUSER_ID, [module_id], None) package.state = 'installed' + for kind in ('init', 'demo', 'update'): + if hasattr(package, kind): + delattr(package, kind) cr.commit() @@ -268,7 +269,10 @@ def load_modules(db, force_demo=False, status=None, update_module=False): if not openerp.modules.db.is_initialized(cr): _logger.info("init db") openerp.modules.db.initialize(cr) - update_module = True + tools.config["init"]["all"] = 1 + tools.config['update']['all'] = 1 + if not tools.config['without_demo']: + tools.config["demo"]['all'] = 1 # This is a brand new pool, just created in pooler.get_db_and_pool() pool = pooler.get_pool(cr.dbname) @@ -278,51 +282,43 @@ 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_demo) + graph.add_module(cr, 'base', force) if not graph: _logger.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)')) # 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'. - report = assertion_report.assertion_report() - loaded_modules, processed_modules = load_module_graph(cr, graph, status, report=report) + report = pool._assertion_report + loaded_modules, processed_modules = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report) if tools.config['load_language']: for lang in tools.config['load_language'].split(','): 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']) \ - or ('all' in tools.config['init']) or ('all' in tools.config['update']): + if ('base' in tools.config['init']) or ('base' in tools.config['update']): _logger.info('updating modules list') modobj.update_list(cr, SUPERUSER_ID) - if 'all' in tools.config['init']: - 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())) - mods = [k for k in tools.config['init'] if tools.config['init'][k] and k not in ('base', 'all')] - ids = modobj.search(cr, SUPERUSER_ID, ['&', ('state', '=', 'uninstalled'), ('name', 'in', mods)]) - if ids: - modobj.button_install(cr, SUPERUSER_ID, ids) # goes from 'uninstalled' to 'to install' + mods = [k for k in tools.config['init'] if tools.config['init'][k]] + if mods: + ids = modobj.search(cr, SUPERUSER_ID, ['&', ('state', '=', 'uninstalled'), ('name', 'in', mods)]) + if ids: + modobj.button_install(cr, SUPERUSER_ID, ids) - mods = [k for k in tools.config['update'] if tools.config['update'][k] and k not in ('base', 'all')] - ids = modobj.search(cr, SUPERUSER_ID, ['&', ('state', '=', 'installed'), ('name', 'in', mods)]) - if ids: - modobj.button_upgrade(cr, SUPERUSER_ID, ids) # goes from 'installed' to 'to upgrade' + mods = [k for k in tools.config['update'] if tools.config['update'][k]] + if mods: + ids = modobj.search(cr, SUPERUSER_ID, ['&', ('state', '=', 'installed'), ('name', 'in', mods)]) + if ids: + modobj.button_upgrade(cr, SUPERUSER_ID, ids) + + cr.execute("update ir_module_module set state=%s where name=%s", ('installed', 'base')) - # Remove that funky global one-shot thingy. - 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 @@ -374,6 +370,9 @@ def load_modules(db, force_demo=False, status=None, update_module=False): # Cleanup orphan records pool.get('ir.model.data')._process_end(cr, SUPERUSER_ID, processed_modules) + for kind in ('init', 'demo', 'update'): + tools.config[kind] = {} + cr.commit() # STEP 5: Cleanup menus From cc6f0aa20a558e24886d48d5746a95994893295a Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 29 Nov 2012 16:36:01 +0100 Subject: [PATCH 2/5] [FIX] potential problem with pyeval datetime/date today()/now() methods. Now only returns the same timezone than server (UTC). bzr revid: nicolas.vanhoren@openerp.com-20121129153601-vtpnvkc0vylo9hux --- addons/web/static/src/js/pyeval.js | 10 +++++----- addons/web/static/test/evals.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/js/pyeval.js b/addons/web/static/src/js/pyeval.js index 265449f9f64..68a7453c958 100644 --- a/addons/web/static/src/js/pyeval.js +++ b/addons/web/static/src/js/pyeval.js @@ -398,14 +398,14 @@ openerp.web.pyeval = function (instance) { now: py.classmethod.fromJSON(function () { var d = new Date(); return py.PY_call(datetime.datetime, - [d.getFullYear(), d.getMonth() + 1, d.getDate(), - d.getHours(), d.getMinutes(), d.getSeconds(), - d.getMilliseconds() * 1000]); + [d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate(), + d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), + d.getUTCMilliseconds() * 1000]); }), today: py.classmethod.fromJSON(function () { var d = new Date(); return py.PY_call(datetime.datetime, - [d.getFullYear(), d.getMonth() + 1, d.getDate()]); + [d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate()]); }), combine: py.classmethod.fromJSON(function () { var args = py.PY_parseArgs(arguments, 'date time'); @@ -442,7 +442,7 @@ openerp.web.pyeval = function (instance) { today: py.classmethod.fromJSON(function () { var d = new Date(); return py.PY_call( - datetime.date, [d.getFullYear(), d.getMonth() + 1, d.getDate()]); + datetime.date, [d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate()]); }), __eq__: function (other) { return (this.year === other.year diff --git a/addons/web/static/test/evals.js b/addons/web/static/test/evals.js index 8e836dade7e..ac6e1f8b0f8 100644 --- a/addons/web/static/test/evals.js +++ b/addons/web/static/test/evals.js @@ -16,8 +16,8 @@ openerp.testing.section('eval.types', { strictEqual( py.eval("time.strftime('%Y-%m-%d %H:%M:%S')", context), _.str.sprintf('%04d-%02d-%02d %02d:%02d:%02d', - d.getFullYear(), d.getMonth() + 1, d.getDate(), - d.getHours(), d.getMinutes(), d.getSeconds())); + d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate(), + d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds())); }); // Port from pypy/lib_pypy/test_datetime.py var makeEq = function (instance, c2) { From f9b9e7c4cb040d6dce43e8ba3616a1453a1d0db9 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 29 Nov 2012 17:07:46 +0100 Subject: [PATCH 3/5] [IMP] added context_today() bzr revid: nicolas.vanhoren@openerp.com-20121129160746-c3c691zk5fxhzse0 --- addons/web/static/src/js/pyeval.js | 17 ++++++++++++----- addons/web/static/test/evals.js | 7 +++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/pyeval.js b/addons/web/static/src/js/pyeval.js index 68a7453c958..4ee9fea0584 100644 --- a/addons/web/static/src/js/pyeval.js +++ b/addons/web/static/src/js/pyeval.js @@ -402,11 +402,6 @@ openerp.web.pyeval = function (instance) { d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds() * 1000]); }), - today: py.classmethod.fromJSON(function () { - var d = new Date(); - return py.PY_call(datetime.datetime, - [d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate()]); - }), combine: py.classmethod.fromJSON(function () { var args = py.PY_parseArgs(arguments, 'date time'); return py.PY_call(datetime.datetime, [ @@ -479,6 +474,17 @@ openerp.web.pyeval = function (instance) { return py.PY_call(datetime.date, [year, month, day]) } }); + /** + Returns the current local date, which means the date on the client (which can be different + compared to the date of the server). + + @return {datetime.date} + */ + var context_today = function() { + var d = new Date(); + return py.PY_call( + datetime.date, [d.getFullYear(), d.getMonth() + 1, d.getDate()]); + }; datetime.time = py.type('time', null, { __init__: function () { var zero = py.float.fromJSON(0); @@ -691,6 +697,7 @@ openerp.web.pyeval = function (instance) { return { uid: py.float.fromJSON(instance.session.uid), datetime: datetime, + context_today: context_today, time: time, relativedelta: relativedelta, current_date: py.PY_call( diff --git a/addons/web/static/test/evals.js b/addons/web/static/test/evals.js index ac6e1f8b0f8..e2dab6e9a17 100644 --- a/addons/web/static/test/evals.js +++ b/addons/web/static/test/evals.js @@ -19,6 +19,13 @@ openerp.testing.section('eval.types', { d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds())); }); + test('context_today', function (instance) { + var d = new Date(); + var context = instance.web.pyeval.context(); + strictEqual( + py.eval("context_today().strftime('%Y-%m-%d')", context), + String(_.str.sprintf('%04d-%02d-%02d', d.getFullYear(), d.getMonth() + 1, d.getDate()))); + }); // Port from pypy/lib_pypy/test_datetime.py var makeEq = function (instance, c2) { var ctx = instance.web.pyeval.context(); From f56badd8252fa62726f68266567d17f5181aa73f Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 29 Nov 2012 17:14:58 +0100 Subject: [PATCH 4/5] [IMP] project_issue private note for phu bzr revid: fp@tinyerp.com-20121129161458-232bfavt2f9lln41 --- addons/project_issue/project_issue.py | 2 +- addons/project_issue/project_issue_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index fe5ce9f325b..55aa0fd557b 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -225,7 +225,7 @@ class project_issue(base_stage, osv.osv): Define Responsible user and Email account for mail gateway.'), 'partner_id': fields.many2one('res.partner', 'Contact', select=1), 'company_id': fields.many2one('res.company', 'Company'), - 'description': fields.text('Description'), + 'description': fields.text('Private Note'), 'state': fields.related('stage_id', 'state', type="selection", store=True, selection=_ISSUE_STATE, string="Status", readonly=True, help='The status is set to \'Draft\', when a case is created.\ diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index 9e25fbca6a6..b7cdfbb0372 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -130,7 +130,7 @@ - + From 720f9093bcfff0996764e655a5b48bfa51062682 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 29 Nov 2012 17:25:31 +0100 Subject: [PATCH 5/5] [IMP] layout issue forms bzr revid: fp@tinyerp.com-20121129162531-26hx9nwmq7f94kp4 --- addons/project_issue/project_issue_view.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index b7cdfbb0372..60cc6448a46 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -111,21 +111,21 @@ - - - + + + +