diff --git a/trytond/trytond/model/modelstorage.py b/trytond/trytond/model/modelstorage.py index c305e0002bb..301b5a9f01b 100644 --- a/trytond/trytond/model/modelstorage.py +++ b/trytond/trytond/model/modelstorage.py @@ -245,6 +245,10 @@ def index_get_field(cls, name): "Returns the index sort order of the field get calls." return 0 + @classmethod + def _must_log(cls): + return bool(Transaction().check_access) + @classmethod def write(cls, records, values, *args): ''' @@ -253,7 +257,7 @@ def write(cls, records, values, *args): pool = Pool() ModelAccess = pool.get('ir.model.access') ModelFieldAccess = pool.get('ir.model.field.access') - transaction = Transaction() + must_log = cls._must_log() assert not len(args) % 2 actions = iter((records, values) + args) @@ -263,7 +267,7 @@ def write(cls, records, values, *args): cls.check_xml_record(records, values) all_records += records all_fields.update(values.keys()) - if transaction.check_access and values: + if must_log and values: cls.log(records, 'write', ','.join(sorted(values.keys()))) ModelAccess.check(cls.__name__, 'write') @@ -331,7 +335,7 @@ def delete(cls, records): if ModelData.has_model(cls.__name__): ModelData.clean(records) - if transaction.check_access: + if cls._must_log(): cls.log(records, 'delete') # Increase transaction counter diff --git a/trytond/trytond/modules/__init__.py b/trytond/trytond/modules/__init__.py index c0c8b69a78f..5ae3950dbbb 100644 --- a/trytond/trytond/modules/__init__.py +++ b/trytond/trytond/modules/__init__.py @@ -300,6 +300,10 @@ def load_module_graph(graph, pool, update=None, lang=None, options=None): # It would deadlock the ir_cache SELECT in the cache when altering # the table anyway Cache._reset.clear() + # The log model may have changed between when the log object was + # created and now (if there was an override of the model), so we + # cannot save any logs + transaction._clear_log_records() transaction.commit() # Remove unknown models and fields Model = pool.get('ir.model')