[FIX] Installation should alert user if any no pool record found for M2M/M2O.

lp bug: https://launchpad.net/bugs/417023 fixed

bzr revid: jvo@tinyerp.com-20100107125352-tmhctw4r71ginntq
This commit is contained in:
Jay (Open ERP)
2010-01-07 18:23:52 +05:30
parent ed1d414dd7
commit 0e7d4a8c8f
2 changed files with 12 additions and 12 deletions
+4 -2
View File
@@ -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
+8 -10
View File
@@ -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))