diff --git a/trytond/trytond/pool.py b/trytond/trytond/pool.py index 407ff358..0be2a41a 100644 --- a/trytond/trytond/pool.py +++ b/trytond/trytond/pool.py @@ -195,6 +195,16 @@ class Pool(object): self.add(cls, type) self.setup_mixin(self._modules, type='report', name=name) return self.get(name, type=type) + elif name[:15] == 'babi_execution_': + import sys + # Do not reload if babi model is accessed during update. + if not sys.argv[0].endswith('trytond-admin'): + with Transaction(new=True).start(self.database_name, 0, + readonly=False): + Execution = self.get('babi.report.execution') + execution = Execution(int(name[15:])) + execution.validate_model(avoid_registration=True) + return self._pool[self.database_name][type][name] raise def add(self, cls, type='model'): diff --git a/trytond/trytond/model/modelsql.py b/trytond/trytond/model/modelsql.py index d762a27a..5ca47c34 100644 --- a/trytond/trytond/model/modelsql.py +++ b/trytond/trytond/model/modelsql.py @@ -1127,8 +1127,14 @@ class ModelSQL(ModelStorage): foreign_table = Model.__table__() foreign_red_sql = reduce_ids( Column(foreign_table, field_name), sub_ids) - cursor.execute(*foreign_table.select(foreign_table.id, - where=foreign_red_sql)) + import psycopg2 + try: + cursor.execute(*foreign_table.select(foreign_table.id, + where=foreign_red_sql)) + except psycopg2.errors.UndefinedTable as ex: + if ex.args and 'babi_execution' in ex.args: + return [] + raise records = Model.browse([x[0] for x in cursor]) else: with transaction.set_context(active_test=False):