diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 0ac375fcde1..4364a5ed555 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -363,7 +363,10 @@ def init_module_objects(cr, module_name, obj_list): logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: creating or updating database tables' % module_name) todo = [] for obj in obj_list: - result = obj._auto_init(cr, {'module': module_name}) + try: + result = obj._auto_init(cr, {'module': module_name}) + except Exception, e: + raise if result: todo += result if hasattr(obj, 'init'): @@ -733,7 +736,6 @@ def load_modules(db, force_demo=False, status=None, update_module=False): if new_modules_in_graph == 0: # nothing to load break - logger.notifyChannel('init', netsvc.LOG_DEBUG, 'Updating graph with %d more modules' % (len(module_list))) r = load_module_graph(cr, graph, status, report=report) has_updates = has_updates or r diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 406aca607f1..2e0778badd6 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1773,11 +1773,10 @@ class orm(orm_template): elif isinstance(f, fields.many2many): cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname=%s", (f._rel,)) if not cr.dictfetchall(): - #FIXME: Remove this try/except - try: - ref = self.pool.get(f._obj)._table - except AttributeError: - ref = f._obj.replace('.', '_') + if not self.pool.get(f._obj): + raise except_orm('Programming Error', ('There is no reference available for %s') % (f._obj,)) + ref = self.pool.get(f._obj)._table +# ref = f._obj.replace('.', '_') cr.execute('CREATE TABLE "%s" ("%s" INTEGER NOT NULL REFERENCES "%s" ON DELETE CASCADE, "%s" INTEGER NOT NULL REFERENCES "%s" ON DELETE CASCADE) WITH OIDS' % (f._rel, f._id1, self._table, f._id2, ref)) cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (f._rel, f._id1, f._rel, f._id1)) cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (f._rel, f._id2, f._rel, f._id2)) @@ -1815,11 +1814,10 @@ class orm(orm_template): # and add constraints if needed if isinstance(f, fields.many2one): - #FIXME: Remove this try/except - try: - ref = self.pool.get(f._obj)._table - except AttributeError: - ref = f._obj.replace('.', '_') + if not self.pool.get(f._obj): + raise except_orm('Programming Error', ('There is no reference available for %s') % (f._obj,)) + ref = self.pool.get(f._obj)._table +# ref = f._obj.replace('.', '_') # ir_actions is inherited so foreign key doesn't work on it if ref != 'ir_actions': cr.execute('ALTER TABLE "%s" ADD FOREIGN KEY ("%s") REFERENCES "%s" ON DELETE %s' % (self._table, k, ref, f.ondelete))