Reviewers: ,
Please review this at http://codereview.tryton.org/561002/ Affected files: M trytond/model/modelsql.py M trytond/model/modelview.py Index: trytond/model/modelsql.py =================================================================== --- a/trytond/model/modelsql.py +++ b/trytond/model/modelsql.py @@ -17,6 +17,7 @@ from trytond.pool import Pool from trytond.cache import LRUDict from trytond.exceptions import ConcurrencyException +from trytond.rpc import RPC _RE_UNIQUE = re.compile('UNIQUE\s*\((.*)\)', re.I) _RE_CHECK = re.compile('CHECK\s*\((.*)\)', re.I) @@ -43,6 +44,8 @@ assert cls._table[-9:] != '__history', \ 'Model _table %s cannot end with "__history"' % cls._table + cls.__rpc__['get_history_tables'] = RPC(instantiate=0) + @classmethod def __register__(cls, module_name): super(ModelSQL, cls).__register__(module_name) @@ -210,6 +213,15 @@ for _, _, error in cls._sql_constraints: res.append(error) return res + + @classmethod + def get_history_tables(cls, record): + cursor = Transaction().cursor + cursor.execute('SELECT write_date ' + 'FROM ' + cls._table + '__history ' + 'WHERE (id=%s AND write_date IS NOT NULL)', (record.id,)) + dates = cursor.fetchall() + return [d[0] for d in dates] @staticmethod def table_query(): Index: trytond/model/modelview.py =================================================================== --- a/trytond/model/modelview.py +++ b/trytond/model/modelview.py @@ -155,6 +155,8 @@ result['view_id'] = view_id result['arch'] = view.arch result['field_childs'] = view.field_childs + result['history'] = (getattr(cls, '_history', False) and + view_type == 'form') # Check if view is not from an inherited model if view.model != cls.__name__: -- [email protected] mailing list
