Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions trytond/trytond/model/modelstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
'''
Expand All @@ -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)
Expand All @@ -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')
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions trytond/trytond/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down